It is not really a question but I wanted to write it down here so other people facing the problem could find the solution.
Since the release of iOS 13
, some of our users were contacting us telling that our app was resetting each time they go into background for a medium amount of time (approximatively 30sec).
Of course, absolutely no clue of the behavior, nothing on Crashlytics
etc. We were able to reproduce on a QA device but unable to reproduce on a debugger attached device.
So obviously we used the Console
to monitor what's going on and we noticed that a weird message was being sent after approx. 25sec after our app was put into background:
default 10:14:01.658579+0100 XXX RunningBoardServices Received process assertions expiration warning!
default 10:14:01.659214+0100 XXX RunningBoardServices Notifying client of imminent expiration of assertion
default 10:14:01.659568+0100 XXX RunningBoardServices Expiration notification complete
If you were fast enough to relaunch the app, everything just worked fine, but if you left the app inactive for another 5sec (approx.) and then relaunched it, then the app was resetting (appDidFinishLaunching
...).
...
No, there is no specific time defined for this.
The answer is simply 600 seconds (10 minutes), reason is provided by the article above.
Use the BackgroundTasks framework to keep your app content up to date and run tasks requiring minutes to complete while your app is in the background. Longer tasks can optionally require a powered device and network connectivity. Register launch handlers for tasks when the app launches and schedule them as required.
...
We dug deeper and deeper without finding anything... until we decided to update some of our external libraries through Cocoapods
, and guess what? we found our guilty guy: GoogleDataTransport
from the Firebase
suite!
We were using the 1.1.3
version and updating to the 3.0.1
fixed the issue. I guess they were doing some "bad" stuff in the background...
That's it guys. I hope it will help some others!
Cheers.
EDIT:
From this page (Firebase
release notes) https://firebase.google.com/support/release-notes/ios#6.11.0, you can read:
Fixed race condition that prevented upload from completing while app was in the background. Version 6.10.0 - October 8, 2019
From what I understand, maybe Firebase
was not notifying iOS that the upload they were doing in the background was completed. It could explain why iOS 13 kills an app in this case.
🤷♂️
EDIT 2:
Apple apparently released an iOS update (13.2.2
) which is supposed to solve these background issues: https://twitter.com/engadget/status/1192512171252551682?s=12.
Fixes an issue that could cause apps to quit unexpectedly when running in the background
We tested it using an old app which does not include our previous fix and unfortunately the problem is still present...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With