gpslogger icon indicating copy to clipboard operation
gpslogger copied to clipboard

Repeats the same coordinates

Open JohnDoe-JohnDoe opened this issue 8 months ago • 4 comments

Hi, I'm trying to set this to be battery efficient to log tracks when I'm walking. I have found that after a couple of hours, presumably when the phone is sleeping/dozing, the points are all exactly the same. I initially had a movement filter and the log showed similar results to #966, 0.0m point discarded. I removed the filter and now the log shows hundreds of points with exactly the same Lon, Lat, Altitude & Accuracy. It appears to be just using the last coordinates received before sleeping. It also does not have a "Time to first fix" entry for these points. Device: Pixel 5 Battery optimisation: unrestricted Location : All the time Use precise location: on Log network: off Log passive: off Logging interval: 60s Distance filter:0.0 Accuracy: 40m Duration to match: 60s Choose best: off Absolute time: 120s

What do I do to make this work reliably in the background? #996 mentions "keep gps enabled" in the app but that drastically reduces battery life. Is there some other settings that I'm missing? Something to trigger a wakeup every couple of hours or to prevent the GPS from completely shutting down?

Thanks JD

JohnDoe-JohnDoe avatar May 03 '25 22:05 JohnDoe-JohnDoe

I think (could be wrong) this is some new update that's been pushed out and not documented anywhere. The reason I say that is because I've started noticing it recently, especially when I was on holiday recently.

I noticed that as soon as I turn the screen off (so presumably some kind of doze mode) the next location received — be it GPS or Network — will suddenly be the an old, stale, cached one. I did some testing in code just today, and if I discard those cached stale ones, new locations simply aren't returned. The location manager only gets one location while the screen is off. 🤷 The logic does the usual, wait for the 'absolute timeout' (120s) before setting the next alarm.

Another observation is that if I keep it going then after 10 minutes, then eventually a non-cached/non-stale location is given. It's almost 10 minutes exactly, which tells me that it's something related to doze.

In my case even "keep gps enabled" makes no difference!

I don't have a fix for the behaviour but I do want to add some code that checks if the location being given is stale/already seen and reject it. It won't fix the problem, just make it very obvious when there are gaps in the logs since the cached locations will now be rejected.

mendhak avatar May 04 '25 18:05 mendhak

I have OS updates turned off, I get the occasional message asking me to update which I keep refusing (when things work fine I don't update as often introduces more problems). It should be Android 14 from about 2023 so unless it sneaked in an update without my knowledge it shouldn't be a new issue. Mine lasts for a couple of hours with the screen off before the old locations are used so slightly different behaviour to yours. I only tried "keep gps enabled" for about an hour as it noticeably drained the battery so not suitable for my requirements. I have previously been using MyTracks (although I haven't used for a few months) which worked quite well and didn't seem to have this issue. My reason for trying a different app is that it doesn't filter out inaccurate results. There must be a way of waking the GPS receiver up in the background otherwise app likes Tile Trackers, Samsung SmartTags & Google Find trackers would be useless?

"add some code that checks if the location being given is stale/already seen and reject it." Just set the distance to 0.1m

It will be disappointing if there isn't some way to fix this as it seriously limits the usability of an otherwise great the app.

JohnDoe-JohnDoe avatar May 04 '25 19:05 JohnDoe-JohnDoe

A library update perhaps, I'm not sure. I did do some library updates in the past few releases. It might be worth testing a previous version if the behaviour is there. There isn't a direct way to fix it that I can see, as the main requesting logic has been unchanged for years!

I'll have to keep playing around to see if there's a way to force fresh locations, but I'm not seeing anything. Almost everything is telling me to use Fused Location Provider, which isn't part of AOSP so wouldn't be accepted in F-Droid.

mendhak avatar May 04 '25 19:05 mendhak

I have tried v130 and v128 with similar results. If anything it is worse, stopping receiving new coordinates faster. My last security update is November 2023 so there shouldn't be any changes to the OS. I'm really surprised more people aren't reporting this issue.

JohnDoe-JohnDoe avatar May 05 '25 13:05 JohnDoe-JohnDoe

v134 is now in the releases and Fdroid

There's some logic added to ignore stale locations.

mendhak avatar Jul 05 '25 08:07 mendhak