Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS App running on iOS 13 is resetting each time the user goes into background for at least 30sec

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...).

...

like image 281
croustibapt Avatar asked Oct 31 '19 07:10

croustibapt


People also ask

Will iOS terminate the app running in background after a specific time?

No, there is no specific time defined for this.

What long running tasks can iOS support in the background?

The answer is simply 600 seconds (10 minutes), reason is provided by the article above.

How do you use iOS background tasks framework to keep your iOS app content up to date?

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.


1 Answers

...

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...

like image 198
croustibapt Avatar answered Oct 01 '22 16:10

croustibapt