Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

High battery usage on Android #33

Closed
eirikurn opened this issue Apr 6, 2020 · 10 comments · Fixed by #53
Closed

High battery usage on Android #33

eirikurn opened this issue Apr 6, 2020 · 10 comments · Fixed by #53

Comments

@eirikurn
Copy link
Member

eirikurn commented Apr 6, 2020

There are multiple reports of high battery usage on Android.

After some research, we've found that the issue is probably in @mauron85/react-native-background-geolocation. It is supposed to save battery when the user is stationary by switching to geofence monitoring. However, this logic seems faulty.

It seems to be implemented with manual GPS polling, and there might be a bug where it is constantly switching between lazy 3-minute intervals and aggressive 1-minute intervals. We'd probably be ok checking every 5 minutes when stationary.

We should either report and/or fix this issue using patch-package (we already have a patch for this package), or we should switch to the ACTIVITY_PROVIDER.

The activity provider uses a Google Play motion API to check if the user is on the move or stationary, which may use significantly less battery than checking the GPS.

@arnigunnar
Copy link

I can confirm the battery issue on my Pixel 2 XL, I see a lot of battery usage for the app on my phone.

@garpur
Copy link

garpur commented Apr 7, 2020

Can confirm the battery issue on my Oneplus 6.

@dingari
Copy link

dingari commented Apr 7, 2020

Can confirm. 54% battery usage since last full charge (Pixel 2XL).

@pjanaya
Copy link
Contributor

pjanaya commented Apr 7, 2020

Can confirm on OnePlus 6 on Android 10. My phone can't keep up the whole day on a single charge, and I'm at home 90% of my day.

@gnarr
Copy link

gnarr commented Apr 7, 2020

Can confirm. My Pixel 2 XL dropped 20% over night when it usually drops between 1-2%.

@eirikurn
Copy link
Member Author

eirikurn commented Apr 7, 2020

Thanks for the confirmations. Please use emoji reactions for +1 style comments and reserve the discussion to collaborate on a fix.

There is an android-gps branch where I'm testing the ActivityProvider on Android. There seems to be some regression there. The foreground service doesn't start and there are no location updates. I haven't had time to look more into it.

@Nafnlaus0
Copy link

Nafnlaus0 commented Apr 8, 2020

One possibility to consider that may additionally help is setMaxWaitTime - the app doesn't need the GPS points returned often, even when it collects them often; infrequent batch responses should be sufficient.

But hopefully ActivityProvider will do the trick, as that sounds like the "proper" solution. This is a very big issue (I hate the fact that this app is cycling my battery so much, and thus reducing my phone's lifespan - all issues of "running out of battery" aside). If it doesn't work, and you still have to use setInterval, consider a very long interval (for example, 15 minutes) whenever the phone stops moving between midnight and 6 AM, until it starts moving again, to minimize nighttime drain; it's exceedingly unlikely that the person will wake up, grab their phone, leave the house and go stand next to a person they don't live near, all within 15 minutes.

Unrelated side note: when rolling out new versions, make sure that the app will automatically restart after being updated. The app didn't restart after my last update. I wonder how many people think they're running the app right now when they're actually not.

@bbalanza
Copy link

@eirikurn I think that the foreground services not activating was a symptom of not having the notifications set up. Foreground state also requires a notification to be presented to the user.

@Dagur
Copy link

Dagur commented Apr 13, 2020

Has this fix been released? It's still using too much battery for me.

@eirikurn
Copy link
Member Author

@Dagur: Unfortunately not yet. There is a regression in the beta release which we haven't had time yet to fix. I hope to fix it tomorrow.

@braulio-balanza. How do you mean? The foreground service and notification are configured here: https://github.com/aranja/rakning-c19-app/blob/master/src/tracking.ts#L31

@Nafnlaus0 the update issue is concerning. We have code that's supposed to address this but apparently it needs more testing.

We'll see how well the ActivityProvider works when we fix the build. Email me if you want to help test beta builds (my email is on my GitHub profile).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants