-
Notifications
You must be signed in to change notification settings - Fork 34
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
Avoid blocking main thread for backupCache calls when leaving app #187
Conversation
eeb37dc
to
1741f15
Compare
That sounds like the right idea. Only problem with the 💡Note: In case of cancellation by the system due to timeout, the block that's passed in is called a 2nd time with the |
@Manuel-Kehl Thank you for pointing that out! I've read the description of the While I think it makes sense to additionally consider adding support for the @winsmith So I think Manuel's concern shouldn't block this from being merged. I suggest we create a separate task for watchOS so we can prioritize it separately from #137, which had high priority as it affects basically every customer. What do you think? |
Based on the documentation here and here:
I am pretty confident that How you manage this PR is of course completely up to you. Guess the benefit of only using Just wanted to share the follow up information and pointers to the somewhat scattered documentation that I had in my own notes from back when I adopted this API, so you can possibly revisit it for future work. On a personal note, I'd love to see this for watchOS, too, because in my experience it happens to be one of the most resource-constrained platforms where the app process tends to get killed by the watchdog most aggressively... 😅 |
@Manuel-Kehl Thank you for your inputs. I am still not convinced that the API guarantees additional execution time. The docs state:
The first paragraph basically states that we are not guaranteed to get an And the docs you quoted above both mention "in case you're in an app extension" or "in case you don't have access to UIApplication". So they seem to be "less recommended" when we DO have access to UIApplication and are inside an app. I have no inside knowledge though, so I might be totally wrong and your suggested API might be just as good. 🤷 |
1741f15
to
275901d
Compare
I tried different approaches to fix #137, even completely converting the entire
SignalCache
to anactor
. But this caused problems with theSignalManager
initializer requiring to beasync
, also it was not compatible with iOS 12.But after a bit of research I came across the
beginBackgroundTask
API which seems to have been invented for exactly purposes like these: We want to write a file to disk exactly when the app is left by the user (and could be killed anytime).According to the docs:
I've never used this API before, so I'm not an expert. But it sounds like it fits perfectly. Let me know what you think!