mendhak/gpslogger

Not logging on android 12 (oneplus) while asleep

Closed this issue ยท 8 comments

Hello,

I recently bought a new phone, oneplus 10pro, on android 12 and it sounds like the app is not able to log positions while asleep.

The application is configured to log every 40sec to a custom URL (auto send disabled). It works perfectly while the screen is on.

I configured everything I can configure on my phone, I followed https://dontkillmyapp.com/

  • no optimization for the app
  • always allow location permission
  • locked the application on recent apps
  • disable optimization while asleep
  • enable background activity
  • Try with and without auto start application

As far as I can see it also happens with my wife's phone: oneplus nord CE 2, but on android 11.

Here is a screenshot of the logging:
At 23:13, I locked my phone.
At 23:18, it sounds the app woke up after 5min and logged.
At 23:22, I unlocked my phone and it logged.

Screenshot_2022-04-26-23-22-43-94_f439cb042244fad5e6ffe93b8d866a3c

Do you know what could I do ?

Thanks,

Thomas

Hi so that yellow message looks a bit unusual. It's showing 0 meters travelled, so the point has been discarded. But 0 in the distance filter should mean, log anything. What value do you have in the distance filter?

Regarding the time interval, I think what you're showing looks about right. With battery optimizations ignored, the app will be slept for roughly 5 minutes rather than 20 minutes. That 5 minute could change in the future, but either way, it is not modifiable. https://developer.android.com/about/versions/oreo/background-location-limits

Thanks for the reply.
Distance filter is 100m, logging interval is 40sec.

The yellow message says "0.0m traveled, point discarded", which sounds good to me because when I was testing yesterday, I was not moving at all.

Oh I see! Yes in that case, since the distance filter is set to a value, what's happening is the app is getting a fix on a point, but the point is being discarded since it doesn't meet the 100m distance filter.

The second part is about the timing, at 5 minutes, that is looking right. Location services are limited to once every 5 minutes even after ignoring battery optimization

Oh I see! Yes in that case, since the distance filter is set to a value, what's happening is the app is getting a fix on a point, but the point is being discarded since it doesn't meet the 100m distance filter.

Yes, and of course this is working as expected.

The second part is about the timing, at 5 minutes, that is looking right. Location services are limited to once every 5 minutes even after ignoring battery optimization

I did some tests today while moving and I could see that when my phone is sleeping, it logs every 5min. So I can see in my history (in home assistant) "big jumps". When my screen is on, the history is smoother.

I used to have the app on my OP5 (android 10 and later 11 with custom rom) and I didn't have "big jumps" like this.
I did some tests with my old phone (gpslogger version 106) and I can confirm it's logging every 40sec, even when sleeping. (Testing while not moving).

Same test but with version 121 and it's also logging every 40sec, even when sleeping

I'm going to do a "moving test" tomorrow with both phones and check what's happening.

Thanks for your help ๐Ÿ™

Hello again !

I did some tests. I think I have a pretty good result:

Blue line is my old phone (OP5, android 11 rom: https://forum.xda-developers.com/t/discontinued-stable-11-0-pixel-experience-11-oneplus-5-5t-dumpling-cheeseburger-official.4198963/).

Purple line is my new phone (op10pro, android 12 stock rom).

Both devices are sleeping while moving. Both have the same config and same app version (121).

You can see that my old phone is giving many more points (and thus a more precise travel), while my new phone gives only 2 points (starting point at home and destination point).

Screenshot from 2022-04-29 11-08-53

How can it be possible ?

I'm not sure how that's possible. Yes I would definitely expect both phones to show the same behavior. If it only has start and end points, that's very unusual, like it's being completely suppressed while the screen is off. Is there anything else running on the OS, or some other properties of the ROM that would cause an extra aggressive battery mode despite all the exemptions?

You can try recording a debug log, you can email it to gpslogger at mendhak.com or post it here (replace the locations with dummy numbers). But note that if the gaps are caused by the 'no optimization' to be ignored, then that will not show up in the logs, it'll simply be a long period of blankness.

Sorry for the late reply.

I think it's definitely related to my phone (one plus on android 11 or android 12).

I also had a try with the homeassistant android app and this is pretty much the same behavior: erratic logging while phone is sleeping. I can see in the log when it's logging every minute that the phone GPS return multiple time the exact same location. And at some point, it logs every 5 minutes (and most of the time the GPS location is the same as the previous) and at some points it completely stops logging.

The only way to get a correct location is to enable the "high accuracy" mode. This is the same as "keep gps enabled" from your app.

So I'll close this issue. Maybe somebody will find this issue will searching and may come with a solution.

Anyway, I would like to thank you for your help and support, and also for the great app ๐Ÿ‘

No worries, thanks for posting an update, it will be useful to someone for sure.