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

fix background poll and and finish it asap #1157

Closed
r10s opened this issue Apr 13, 2021 · 4 comments · Fixed by #1552
Closed

fix background poll and and finish it asap #1157

r10s opened this issue Apr 13, 2021 · 4 comments · Fixed by #1552

Comments

@r10s
Copy link
Member

r10s commented Apr 13, 2021

currently, performFetchWithCompletionHandler and didReceiveRemoteNotification let run the core IO for 10 seconds and terminate then.

it would be better to terminate once a fetch on the imap folders INBOX and DeltaChat is done (there is some info-message, but no dedicated event, maybe core needs some adaptions) AND there are no more pending jobs (eg. sending messages out).

that way:

  • we would usually return after a second or so and would get called faster again
  • if a fetch really takes 10~20 seconds, that can be completed as well (after ~20 seconds, however, better terminate IO gracefully and call the completion handler properly) (absolute max. would be 30 seconds, however, at that point we risk to be brute-force-terminated and not to be called soon again)
@r10s r10s added the enhancement actually in development, user visible enhancement label Apr 13, 2021
@r10s
Copy link
Member Author

r10s commented Apr 20, 2021

some numbers:

on my iphone7, ios1.14.2, in the last 23½ h:

  • 143 wakeups in total (68 remote, 75 local, in average one wakeup every 10 min)
  • this should be 143 * 11 s (10 s wait, 1 s terminate) background time = 26 min
  • battery stats say 36 min in background, however, i assume, this includes the 30 s after leaving the app - so i have left the app 20 times (36 min - 26 min = 10 min = 20 * 30 s) today, which is reasonable

so, assuming an fetch with no data is not much more than one second, the 26 min can probably be reduced to a fragment - which, all in all, should get us a better reputation to be called more often (i do not expect to be called more than every 10 min, but there are phones with more apps where we are currently called less often)

@cyBerta
Copy link
Contributor

cyBerta commented Jun 9, 2021

This issue should be postponed until multi-account is implemented

@r10s
Copy link
Member Author

r10s commented Jun 17, 2021

after some discussions, we found out, that DC_EVENT_CONNECTIVITY_CHANGED that will be introduced in deltachat/deltachat-core-rust#2319 is mostly suitable:

  • when receiving DC_EVENT_CONNECTIVITY_CHANGED and dc_accounts_get_connectivity() equals DC_CONNECTIVITY_CONNECTED, we're done.

  • the existing call to dc_maybe_network() makes sure that the status really changes as expected.

@r10s
Copy link
Member Author

r10s commented Feb 3, 2022

just had a look, for the code, https://github.com/deltachat/deltachat-ios/pull/1221/files is still a pretty nice pattern.

@r10s r10s added bug and removed enhancement actually in development, user visible enhancement labels Mar 5, 2022
@r10s r10s changed the title finish background poll asap fix background poll and and finish it asap Mar 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants