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

sometimes unacceptable battery usage #1858

Closed
havet opened this issue Apr 7, 2021 · 23 comments
Closed

sometimes unacceptable battery usage #1858

havet opened this issue Apr 7, 2021 · 23 comments
Labels
needs-feedback needs retry or more info must be provided

Comments

@havet
Copy link

havet commented Apr 7, 2021

  • Operating System (Linux/Mac/Windows/iOS/Android): Android 8.0.0
  • Delta Chat Version: 1.14.5
  • Expected behavior: Battery usage as the default e-mail app (4% for several accounts)
  • Actual behavior: More than the double for only one account (9 %)
  • Steps to reproduce the problem: Install and use a day or two.
  • Screenshots: NO
  • Logs: Not of any interest.
@Hocuri
Copy link
Collaborator

Hocuri commented Apr 7, 2021

Did you use Delta Chat a lot? Then this would be the explanation, as, well, using an app needs battery.

Otherwise, you can send a log, maybe we find the reason for the high battery drain in there.

@gerryfrancis
Copy link
Contributor

gerryfrancis commented Apr 7, 2021

@havet In all conscience, your issue description is not very helpful. I am with @Hocuri : To find out what is wrong with your instance of Delta Chat, we need more information, e.g. a log that tells us what is going on in the background. (You can anonymize your log with a text editor before you upload it here.)

@havet
Copy link
Author

havet commented Apr 7, 2021 via email

@gerryfrancis
Copy link
Contributor

@havet Thanks for uploading the log. How many accounts do you use with Delta Chat, and which mail providers?

@havet
Copy link
Author

havet commented Apr 22, 2021

Hi, my mail answer seems to have got lost.
At the time when I posted the log, I used only one account on my Android phone. I've got that e-mail address hosted at websupport.se (owned by one of the greatest Swedish web hosting companies, Loopia Group).

@havet
Copy link
Author

havet commented Apr 22, 2021

By the way ...
I suggested e-mail notifications as a work around for notification problems on iOS. It strikes me that such a feature might be useful for Android as well for battery saving. With that option activated you won't have to have Delta Chat running in the background. You open Delta Chat when you get an e-mail notification.

  1. The e-mail app checks mail quite often and notifies OK.
  2. The user sets the option: 'Send e-mail notifications' and adds an e-mail address for notifications (Default: the same as used in Delta Chat. If he uses a dedicated account for Delta Chat, different from his mail account, he must enter his e-mail account instead.)
    Optional: a test-mail is sent to the notification e-mail address, for verification.
  3. DC puts the option "send e-mail notification to 'notification address'" in outgoing chat messages.
    e.g. something like "Preference: Send e-mail notification to user@server.*"
  4. The receiving Delta Chat app notices that the other part wants e-mail notifications and sends a notification e-mail to the notification address after each chat message.
  5. The original user gets notified by his e-mail application and opens Delta Chat to begin the chat.

@gerryfrancis
Copy link
Contributor

gerryfrancis commented Apr 22, 2021

@havet Many thanks for your suggestions. An issue that led to high battery consumption was found (and fixed), see deltachat/deltachat-core-rust#2335 . A PR to fix the issue has been merged. You can check out the next nightly build available presumably tomorrow here https://download.delta.chat/android/nightly/ or wait for the next official release. However, please report back whether things turn to the better or not. Thanks!

@adbenitez
Copy link
Member

this needs retry with version 1.20.2

@adbenitez adbenitez added the needs-feedback needs retry or more info must be provided label May 14, 2021
@r10s
Copy link
Member

r10s commented May 14, 2021

4% vs 9% - that may also come from the fact that Delta Chat runs all the time, doing IMAP-push by default, where the "default e-mail app" may use (a) google-push (depending on the used provider and the app) or (b) just poll. not to talk about screen time and other things that may affect things.

but, of course, maybe there is a bug that results in higher battery usage, some mail may stuck etc. we had that in the past as well, so it is worth rechecking with the current version; maybe that results in an actionable item.

@havet
Copy link
Author

havet commented Jun 13, 2021

Retry with DeltaChat v. 1.20.2
A day with unusually little use of both e-mail and DeltaChat the mail-app used 1% and DeltaChat 5 %. I read approximately 5 e-mail and sent one e-mail. I sent one DeltaChat message.

@gerryfrancis
Copy link
Contributor

@havet Please post a current log file, maybe we can figure out the cause. Thanks in advance.

@csb0730
Copy link

csb0730 commented Jun 14, 2021

@havet
Do you have bad network conditions? This is a possible reason to see a higher battery drain.

You may try this apk for a trial:
https://github.com/csb0730/deltachat-android/releases/download/v1.2.14-beta/deltachat-fat-debug-1.2.14-beta.apk

I changed internal core approach of imap and smtp connection handling with that version.
Typical battery drain is <2% with that. Even < 1% (not in Androids list) is seen most of time!

It would be interesting if that version shows a different behaviour for you.

@havet
Copy link
Author

havet commented Jun 15, 2021

No, I have excellent network conditions. Fiber 1GB/s at home and excellent 4G connection.
And the e-mail app would suffer equally from bad network conditions, wouldn't it?

I´m not able to test any new versions during the summer.

I might contribute a log in a few days, I'm busy for the moment.

@csb0730
Copy link

csb0730 commented Jun 15, 2021

The reason for high battery usage while a flaky network conditions is
that every time network comes and goes away imap idle is interrupted and a reconnect and fetch is triggered.
It depends on how worse it is this generates much activity in the background. Event more worse, when there are pending jobs for smtp which are waiting to be completed. You can see this in log 👍

I think you know that DC tries to make imap idle as long as possible (~23min) to save resources. This approach is very efficient when it is possible. But it isn't sometimes :-)
And that's exactly the point where I adaped imap idle approach.

@racuna
Copy link

racuna commented Sep 29, 2021

Same problem here (MIUI 11, Android 9). Last beta of Delta Chat from the Play Store.

Went to camping (sept 18th) to a lake (not much signal there). Battery drained fast even when I barely took off the phone of my pocket. Just to take pics here and there.

So, I opened battery stats. Delta Chat was the top 1 battery drainer. I had to uninstall it to have juice for the rest of the day for useful apps in the outdoor like Trail Sense, OSM, or just the camera.

@ghost
Copy link

ghost commented Sep 29, 2021

@racuna It is as csb0730 says, if there are poor signal conditions or DC connection losses it consumes. I don't know if trying the apk that csb0730 recommended improves the situation, if yes, it could be a solution. 🤔

@csb0730
Copy link

csb0730 commented Oct 3, 2021

Have a look into the sources I'm using. Maybe you understand what I did.

The difficulty was to determine bad network conditions properly and adapt internal job and reconnect handling accordingly AND keep response level high and accurate (make imap idle as long as possible under every condition and prevent every unnecessary action!).

In any case my self compiled DC is working fine under all conditions. I'm using it for quite a year now and don't feel the need for any change. I'm very happy with it. I just works and never generates high battery drain. :-)

@gerryfrancis
Copy link
Contributor

@csb0730 As I do not have the skills to read the code, two questions: Is it possible that idle time varies from server to server? Can it be determined reliably?

@csb0730
Copy link

csb0730 commented Oct 7, 2021

1a) I did not do any research for several different servers, but theoretically it is.
But there is a standard of 29 min for maximum idle duration which is used quite often. I think shorter max idle durations are possible. When maximum idle duration is reached you see a connection close of peer in logfile (but only if network connection is reliable!!).
1b) Max idle duration depends on network type too (!) I saw a significant difference in home wlan (max 15 min) and mobile communication (max 29 min).
2) To determine all this I extended DC core's logging, introduced a much shortened connection verification loop in core and verified timing with timers instead of waiting for connection timeout (which was very unreliable before).
With that, I'm able to see exactly what's happening internally in reality in logfile.

Maybe this gives you a little bit more feeling about the improvements I did.

Important:
For a reliable operation local device needs to detect connection close by peer properly or needs to detect bad wifi status and close an idle connection actively before end of max idle duration.

@racuna
Copy link

racuna commented Oct 7, 2021

How about increasing the idle time when connection is not possible? (with a maximum time) and restart the idle time to minimum when connection returns?

I think gmail web client have something like this, if I recall correctly.

@csb0730
Copy link

csb0730 commented Oct 7, 2021

All you described I did and even more!
My approach is much more complicated as I described it in this short text above.

An adaptive dynamic imap idle duration handling (1) is the base but also accurate detection of connection status (2) and synchronized smtp job handling (3) and prevent too many idle interrupts (4) are all important for an efficient and reliable operation of DC.

See here deltachat/deltachat-core-rust#2208 for more details.

@havet
Copy link
Author

havet commented Oct 12, 2021 via email

@r10s r10s changed the title Unacceptable battery usage sometimes unacceptable battery usage Mar 9, 2022
@adbenitez adbenitez removed the needs-feedback needs retry or more info must be provided label Mar 14, 2022
@adbenitez
Copy link
Member

this need to be retried with 1.28, if it keeps happening please re-open this issue and provide fresh logs

@adbenitez adbenitez added the needs-feedback needs retry or more info must be provided label Mar 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-feedback needs retry or more info must be provided
Projects
None yet
Development

No branches or pull requests

7 participants