element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
GNU Affero General Public License v3.0
3.39k stars 731 forks source link

Battery Drain on FDroid Build #5640

Open benneti opened 2 years ago

benneti commented 2 years ago

Steps to reproduce

  1. Install FDroid build and login
  2. Enable notifications and background sync
  3. let phone in a drawer for a few hours
  4. check battery usage
  5. see huge drain due to element (Also element never went to the background according to the phones battery information)

Outcome

What did you expect?

Element should go to the background and try to save a bit more battery.

What happened instead?

Element is seen as active even in the locked phone state and drains a lot of battery.

Your phone model

Fairphone 4 (5G)

Operating system version

Android 11

Application version and app store

Element 1.4.4, olm 3.2.10 from F-Droid

Homeserver

synapse homeserver 1.54.0

Will you send logs?

Yes

benneti commented 2 years ago

Battery usage screenshots:

Screenshot_20220326-081932 Screenshot_20220326-081838 Screenshot_20220326-100017

EDIT: Also relevant notification setting

gdkrmr commented 2 years ago

Same issue here on a Moto g 5g. The point where the curve becomes flat is where I have killed the app.

image

benneti commented 2 years ago

Also, I switched to the gplay version for now, because there the drain seems normal.

ouchadam commented 2 years ago

Does increasing the sync interval from 60 seconds to 300 (1min to 5mins) help?

If increasing the interval reduces the battery drain then unfortunately the app is behaving as expected. The fdroid variant is using an interval polling mechanism to check for new messages which means (if the OS/ROM allows for it) the device will wake up every 60 seconds. Some OEMs/ROMs incorporate an exponential backoff when a device becomes inactive/dozing whereas others will allow for exact repeated scheduling.

The google play variant uses Google Play Services and FCM to only wake up the device when a message is received, drastically reducing the amount of wake ups needed.

If increasing the interval does not reduce the battery usage then we can investigate further as this may mean there's a rogue service running non-stop

benneti commented 2 years ago

I think I tried to increase the poll interval (to a few minutes) with no significant effect but I did not do any comparison measurements; right now I use the google play version, but I will double check.

benneti commented 2 years ago

Actually I think I cannot reproduce this anymore on 1.4.8. I'll keep an eye on the battery drain for the next few days with the 60s intervall but after two hours in the background right now it says 0% used which is what I would expect!

benneti commented 2 years ago

After leaving it in running in the background over night, it only drew about a percent in the same hour as the 10% before which I think is fine. @gdkrmr is it better for you on 1.4.8 or is it still drawing much?

ouchadam commented 2 years ago

That's great news, thanks for confirming! Battery is one of those tricky areas where the GooglePlay variant and FDroid behave differently, along with OEMs/ROMs having their own sets of battery optimisations.

There's nothing that stands out in the changelog from 1.4.4 to 1.4.8 that specifically targets battery issues which has me a little paranoid that we could unknowingly reintroduce the issue in the future

if we get more confirmations or no new reports in a few days, I'd be tempted to close this issue

Mindavi commented 2 years ago

I'm having quite a bit of battery drain too. I wasn't sure where it was coming from but I can confirm that element is at the top of the list for battery usage (at 19%).

I'm running 1.4.14, I think from F-Droid.