This object is in archive! 

Battery Drain/Constant Wakelock

Ingo Rau shared this problem 6 years ago
Solved

Let me get this out of the way first: This is about using an unofficial LineageOS build. I just thought you might give me some pointer where to try out different settings.

I just installed LineageOS 15.1 (as mentiones, unofficial) on my old Galaxy Note 4. All works fine, GPS accuracy just like before - but it's eating away the battery like crazy when recording a track. Turning on Flight Mode, changing the GPS method in Locus, doesn't change anything. I switched off background scanning in Location settings, too.


Now I have two other phones with LineageOS 15.1 (official), where Locus battery consumption is minimal, especially in Flight Mode. Also, when I still had CM12.1 on the Note4, it was minimal.

An analyzer app tells me, that Locus keeps constante Wakelock while recording. Doesn't do that on other phones.

As I said, I'm aware that this might be entirely the ROM's fault - but perhaps you know some stuff I could check/try out. After all, you probably spend quite some time on battery related issues before... Thx!

Replies (12)

photo
1

Good day Ingo,

wakelock is held when GPS is needed and also following conditions are met:

  • the device is not Huawei with Android 6.0+
  • you use good old location system in Locus, not new "Google location assistant services"

So if you think that this wakelock cause a trouble, try to use Google location assisted service to obtain location in Locus. Then wakelock should not be used.

There are also three services in Locus that hold wakelock during it's work: backup service, tasks service (tasks running in notification center) and Geocaching offlinizer.

Hope you find something useful from what I wrote. Otherwise feel free to ask.

photo
1

Thx a bunch for your reply. I installed a new build for that phone, and at first it looked like it got better, but on second try it was just as bad. Will do a full comparison of several phone son the weekend.

Additional question: What about Android Oreo's "Battery Optimization"? Is it OK to set Locus to "Battery Optimized" or does that mean the system could kill the recording process? So far, I always exempted Locus from optimization, but perhaps that's the mistake?!

photo
1

Battery optimization is an older system that should put apps to sleep when not needed. Anyway, how it will behave on your device, hard to say. More and more, every Android work differently. Best is to try it. Let Locus be affected by this battery optimization and if you notice any problems with sleep (of Locus Map), just next time exclude it. On my S7 device, this optimization has no effect for example.

photo
1

I did a big comparison on the weekend: 5 phones (3x 8.1, 1x7.0, 1x5.1), one test just lying on the window sill for 2hrs, one test on a 3hr bike tour. The Oreo results on the two newer phones (Note4, S9) are abysmal, especially on the Note4 (only <25% left after the bike trip, whereas the S5neo with 5.1 still had 87%). Surprisingly, the S4 with an unofficial LineageOS showed more or less normal battery usage.

One strange thing: SystemPanel2, which on Oreo can show app-specific usage, doesn't show especially high CPU/battery usage by Locus, but as soon as Locus records, the usage by System (or "Unaccounted" on the Note4) skyrockets.

I know, it's LineageOS, and one is even unofficial, but I think it's at least possible that Locus does something that was fine on older systems, but is problematic now on Oreo, isn't it?What I also noticed: I did tests with "Google location assistant services" and without, as you proposed, but in both modes SystemPanel2 shows me 100% wakelocks held by Locus. If I understood you correctly, that shouldn't be the case...

I've attached the SystemPanel2 overviews (battery/cpu/wkaelock) for 1hr recording with my Note4.

photo
1

Hmm interesting, thanks for tests!

Isn't in this nice tool that displays battery consumption, option to display name of wakelocks that app held? Every wakelock has its name so maybe it should be possible to detect what is the name of this that cause trouble. Thanks.

photo
2

Unfortunately no, but I will install good ol' Wakelock Detector and see what that shows...

photo
1

First result: In Wakelock Detector, Locus doesn't show up under "CPU wakelock", only under "Wakeup triggers" - but there's no name displayed :( Do you know any other app that might display this?

photo
1

Well, now I got something useful, I think: Better Battery Stats shows 96% Locus GpsConnectionBaseImpl under Partial Wakelocks. Under Kernel Wakelocks, it's 100% PowerManagerService.WakeLocks and 98% msm_hsic_host.


And 150 wakeups (6/min) by menion.android.locus.pro under Alarms, but that's probably ok.

I could export the BBS dump, if that's any help to you?

photo
1

Hi, then I do not see any problem. Mentioned 6 wakeups per minute is Locus method, how to keep CPU/Locus Map/device awake and receive location. Because of permanent problems with GPS usage on various devices, this is one method that proved to be working. So Locus Map holds PARTIAL_WAKE_LOCK and together with this send every 10 seconds request to keep device "more awake". Anyway, this whole system is disabled in case of using mentioned "Google assisted GPS location", where is no PARTIAL_WAKE_LOCK and no triggers to keep device awake.

To be true, what some apps display is not important. More important is if the app really sucks your battery faster then should or not. So if you use "Google assisted", is battery consumption also high as in the second case? Anyway weird that is cause such troubles only on your Lineage OS device.

photo
1

Well, fact is that only when Locus is recording, device is awake almost 100% of the time, which sucks battery like crazy. I asked in the respective XDA forums, but there don't seem to be widespread problems with GPS on LineageOS. Don't get me wrong, I'm not blaming you ;) But there is probably some combination of Locus way of doing things together with something in LOS.

Anyway, when I tested on the weekend, "Google assisted" didn't make any difference in battery consumption - but I didn't check wakelocks etc. I'll try that again now. Will get back to you...

photo
1

Well, you're right: With "Google assisted", the GpsConnectionBaseImpl wakelock is gone, the biggest wakelock is now Locus' NlpWakeLock, but only with 4%.

However, CPU consumption (and phone temperature) stays high, as the phone doesn't seem to go to Deep Sleep, in fact it mostly stays at max. frequency... So it looks like wakelocks are not the problem, but the system fails to go sleep. So it's not Locus, but some system process further down the road that because of Locus' usage pattern decides to not go to deeper sleep.

So will have to try my luck again on the XDA forums. Anyway, if you have any other idea what I could try...? Might play around with Greenify a little...

photo
1

But why you wants from system to go to sleep? Point of all these systems in Locus as well as of wakelocks is to prevent system to go to sleep! If your system is put to sleep, then Locus Map stops work, GPS stops updates etc!

photo
1

OK, sorry, i got that wrong. Deep sleep while recording is of course not possible. But according to BBS, the CPU is at maximum frequency at lot, even when screen off - that shouldn't be, am I right? That would definitely explain the drain and high temperature.

photo
1

Ah here a the problem. Yes, it should be it. So seems that enabled wake lock not just keep CPU awake (which is correct), but some process also put cpu usage to max.

If you start Locus Map, enable track recording and let screen turned on ... you see this huge CPU usage, right? So not just in case, screen is off or Locus is in background. If so, are you using (have installed) Beta version? Please do it if possible. In beta version, when CPU is so high, press long-click! on top left main menu button and you get dialog with "Measure method usage" option. Tap it and let Locus Map be with screen turned on till you see "Tracing finished into file ... ". Should take 70 seconds. Directly in Locus directory will be then generated "tracing" file, so send me it please. It should contain CPU usage of every feature in app that was used. If there will be any issue in code, I should see it here. Thanks.

photo
1

Sent you the trace by email.

photo
1

Thanks for a logs (received over private ticket) Ingo,

have to say, there is nothing unusual. Maybe little more work/CPU usage on work with NMEA messages (do you have enabled NMEA recording?), but nothing serious ... weird.

I'm worried, I can't help here too much. You may give a try to one thing .. does this happen only with Locus Map? You may in GPS screen > top toolbar > simulation, enable simulation of GPS and start recording or what you do as usual. To see, if enabled GPS system causes trouble. Then I may suggest trying to use a different application, to confirm that the problem is in Locus Map itself and not generally in your ROM.


Jiří M. aka Menion

photo
1

Hi Menion

Thx a bunch for the analysis. After I saw a few other comments regarding high CPU usage/hot phone when doing navigation on the respective XDA thread, I have to assume that it is a problem of the ROM after all.

I'm off to a Locus-free weekend now, will try that GPS simulation as soon as possible.

Anyway, two more remarks:

- When recording a long time, there are phases with very little CPU usage (just as one would hope for all the time), usually after there has not been much movement. When I turn the screen on or start to move again, it usually picks up.

- No, not using NMEA (set to "never")

First thing probably doesn't help, but I would say it's a little weird that there is any action at all with NMEA, when it's turned off. Perhaps this triggers some other bug in the system, which would go unnoticed otherwise...

Anyway, have a great weekend!

photo
1

Hi,

oki, glad to hear it (that issue is most probably in ROM and not in Locus itself).

About NMEA messages: Locus register itself as possible NMEA reader no matter if these messages are saved into file or not. Based on your log it looks, that this add some additional work to GPS system. I'll try to improve this in next version and register Locus really only in case, NMEA messages will be needed.

Let me know if there will be something more I may help with.

Menion

photo
1

Thx! Is that little improvement already in 3.32?

photo
1

If we talk about better support for NMEA recording (better no NMEA handling when not needed), then no. But I have this in my task list for version 3.33.

photo
1

3.32.2.2 with NMEA fix: No real effect. :( Like I had once before, it started off with acceptable CPU usage, but then took off again (after I turned screen on/off). Phone doesn't seem to get as hot, but battery just like before.

Given how much I read about GPS hot phone issues (also with Google Maps for example) with this ROM in the XDA thread, I'm positive it's not Locus. So thx a lot for trying to find a solution/imporvement, Menion, but I think you can drop this on your end!

photo
1

Hello, thanks for information. I did not expected any extra visible effect to be true. Anyway it make sense, not to receive NMEA data when you does not need it at all. So saved a little CPU is nice benefit.

Anyway I also think it won't be an issue caused by app itself.

Menion

Replies have been locked on this page!