question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Location tracking issue

See original GitHub issue

Home Assistant Android version: 2.2.1-29-g5ee23a7-303-full Android version: 9 Phone model: Motorola G7 Plus Home Assistant version: 0.114.4 Last working Home Assistant release (if known):

Description of problem:

As a continue of #698.

I’ve just built the latest master to check if the location issues are fixed. I’ve upgraded from 2.0.0-3-g11982f9-238-full to 2.2.1-29-g5ee23a7-303-full.

When using the old version, location updates were received every 2-3 minutes if the app is opened in the background or every 15 minutes (sensors update interval) if the app is closed.

After some time the opened app stopped receiving location updates. This is pretended to be fixed by commit 63ded1a1d35b75adf7fa6cbeaf217947c802c0cd Hopefully fix the background location updates randomly stopping.

Now I’m using the latest version and what I see…,

Location updates are received exactly every 15 minutes (sensors update interval) and not more often irrespective of that the app is opened or closed. Or on forced sensors update (charger connection, bluetooth connection and so on). Location updates every 2-3 minutes are gone.

Is this a bug or am I missing something?

BTW, as I see from the log, on the app opening the location sensor update is requested multiple times:

08-27 16:03:22.170  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.173  6734  6820 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.180  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.187  6734  6820 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.191  6734  6820 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.192  6734  6821 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.194  6734  6824 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.204  6734  6821 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.204  6734  6824 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.210  6734  6824 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.212  6734  6821 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.347  6734  6821 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:23.353  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:23.356  6734  6821 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:23.358  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:23.362  6734  6821 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.362  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates

And even on the scheduled sensors update it is requested twice:

08-27 16:18:24.211  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:18:24.218  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:18:24.219  6734  6820 D LocBroadcastReceiver: Removing all location requests.
08-27 16:18:24.224  6734  6820 D LocBroadcastReceiver: Registering for location updates.
08-27 16:18:24.227  6734  6820 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:18:24.231  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates

Can’t be there some kind of race condition because of that?

The full log is below. The app was opened at 16:03 and kept running.

Traceback (if applicable):

08-27 16:03:22.170  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.173  6734  6820 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.180  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.187  6734  6820 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.191  6734  6820 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.192  6734  6821 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.194  6734  6824 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:22.204  6734  6821 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.204  6734  6824 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:22.210  6734  6824 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:22.212  6734  6821 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Got single accurate location update: Location[fused 55,637364,37,357052 hAcc=58 et=+19h2m41s167ms alt=201.90000915527344 vel=0.1477595 bear=189.81027 vAcc=2 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=52]}]
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.130  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.347  6734  6821 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:23.353  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:23.356  6734  6821 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:23.358  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:23.362  6734  6821 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.362  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.537  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.537  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.537  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.537  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.537  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.539  6734  6734 D LocBroadcastReceiver: Got single accurate location update: Location[fused 55,637364,37,357052 hAcc=58 et=+19h2m41s192ms alt=201.90000915527344 vel=0.1477595 bear=189.81027 vAcc=2 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=52]}]
08-27 16:03:23.539  6734  6734 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
08-27 16:03:23.540  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.540  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.540  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.540  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.603  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.612  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.612  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.612  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.612  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.612  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.629  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.636  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.640  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.640  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.640  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.640  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.649  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.661  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:03:23.680  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:03:23.691  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:03:23.811  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.811  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.811  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.811  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.811  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.830  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.837  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.837  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.837  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.837  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.837  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.843  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.903  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:23.904  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:23.904  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:23.904  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:23.904  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:03:23.921  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:03:24.070  6734  6734 D LocBroadcastReceiver: Got single accurate location update: Location[fused 55,637364,37,357052 hAcc=58 et=+19h2m42s124ms alt=201.90000915527344 vel=0.1477595 bear=189.81027 vAcc=2 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=52]}]
08-27 16:03:24.070  6734  6734 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
08-27 16:03:24.071  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:03:24.071  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:03:24.071  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:03:24.071  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:18:24.211  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:18:24.218  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:18:24.219  6734  6820 D LocBroadcastReceiver: Removing all location requests.
08-27 16:18:24.224  6734  6820 D LocBroadcastReceiver: Registering for location updates.
08-27 16:18:24.227  6734  6820 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:18:24.231  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:18:24.439  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:18:24.441  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:18:24.441  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:18:24.441  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:18:24.441  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:18:24.445  6734  6734 D LocBroadcastReceiver: Got single accurate location update: Location[fused 55,637364,37,357052 hAcc=58 et=+19h17m42s527ms alt=201.90000915527344 vel=0.1477595 bear=189.81027 vAcc=2 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=52]}]
08-27 16:18:24.446  6734  6734 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
08-27 16:18:24.446  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:18:24.446  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:18:24.446  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:18:24.446  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:33:39.918  6734  6780 D LocBroadcastReceiver: Removing all location requests.
08-27 16:33:39.924  6734  6780 D LocBroadcastReceiver: Registering for location updates.
08-27 16:33:39.927  6734  6820 D LocBroadcastReceiver: Removing all location requests.
08-27 16:33:39.928  6734  6780 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:33:39.933  6734  6820 D LocBroadcastReceiver: Registering for location updates.
08-27 16:33:39.938  6734  6820 D LocBroadcastReceiver: Registering for zone based location updates
08-27 16:33:40.159  6734  6734 D LocBroadcastReceiver: Got single accurate location update: Location[fused 55,637364,37,357052 hAcc=58 et=+19h32m58s259ms alt=201.90000915527344 vel=0.1477595 bear=189.81027 vAcc=2 sAcc=1 bAcc=??? {Bundle[mParcelledData.dataSize=52]}]
08-27 16:33:40.159  6734  6734 D LocBroadcastReceiver: Location accurate enough, all done with high accuracy.
08-27 16:33:40.160  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:33:40.160  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:33:40.160  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:33:40.160  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027
08-27 16:33:40.174  6734  6734 D LocBroadcastReceiver: Received location update.
08-27 16:33:40.175  6734  6734 D LocBroadcastReceiver: Last Location:
08-27 16:33:40.175  6734  6734 D LocBroadcastReceiver: Coords:(55.6373635, 37.3570516)
08-27 16:33:40.175  6734  6734 D LocBroadcastReceiver: Accuracy: 57.53
08-27 16:33:40.175  6734  6734 D LocBroadcastReceiver: Bearing: 189.81027

Screenshot of problem:

Additional information:

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:34 (31 by maintainers)

github_iconTop GitHub Comments

1reaction
anyuta1166commented, Aug 29, 2020

Thank you 😃

Opened PR #843 for most obvious things.

0reactions
anyuta1166commented, Aug 30, 2020

So after some testing I should say that location updates do work even if the app is closed, thanks to the periodic work that re-registers subscription for location updates. It works perfectly on Android <= 7. BUT it is very unreliable on Android 9+ (I’m not sure if Android 8 is affected, I don’t have devices with this Android version). Sometimes periodic work does it’s work, but location updates are not received. Sometimes even the periodic work is delayed by up to 2 hours (!), despite it is declared to be run every 15 minutes, so we have up to 2 hours with no sensor and location updates at all. The latter happens when the phone left intact for some time. Probably this is the improved doze mode. If I just grab the phone, unlock it and put it back, periodic work continues to run every 15 minutes and location updates are started to be received again even if I don’t launch the app.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Top 5 common problems with app location data and how to ...
Top 5 common problems with app location data and how to solve them · 1. Inaccurate and imprecise data · 2. High battery...
Read more >
Most Common GPS Tracking Problems Experienced by Users
Location tracking is not accurate. ... Accuracy problems are usually caused by an error in location. It's probably because your antenna is having ......
Read more >
Location Tracking: A Pervasive Problem in Modern Technology
We've already noticed that location tracking is an inherent part of the way today's cell phone infrastructure is put together—we can't make some ......
Read more >
Top 6 Ways to Fix Location Services Not Working on Android
Is your phone failing to detect your location? Go through these troubleshooting tips to fix location services not working on Android.
Read more >
How Google's location-tracking issue affects you - Engadget
This week, the Associated Press published the findings of its investigation showing that Google tracks your locations even if you've shut off ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found