Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS app getting killed in background - how to debug?

Tags:

ios

swift

lldb

My iOS app gets terminated when put in background. I get the following logs in the device console:

Background Task 160 (""), was created over 30 seconds ago. In applications running in the background, this creates a risk of termination. Remember to call UIApplication.endBackgroundTask(_:) for your task in a timely manner to avoid this.

followed by

Background task still not ended after expiration handlers were called: . This app will likely be terminated by the system. Call UIApplication.endBackgroundTask(_:) to avoid this.

and the app terminates and restarts on resuming from background

The new metric kit background exit data (iOS 14) is also reporting that BackgroundTaskAssertionTimeoutExits are killing my app

On breaking on UIApplicationEndBackgroundTaskError, I get the following backtrace:

UIApplicationEndBackgroundTaskError backtrace

I have not implemented any background tasks myself but there are some third party libraries integrated in the app that do.

What is the right way to debug this?

like image 959
AkshatK Avatar asked Nov 19 '20 07:11

AkshatK


1 Answers

If you did not start any background task, and you do not perform anything most likely some of your 3rd party frameworks are causing the crash.

Update to latest version of all your dependencies, to see if the issue was fixed.

If your issue is easily reproducible, try to disable them 1 by 1 to see which is causing the crash.

After that go on the library support page and see if there are any bugs for your issue and if not open a bug.

Start with the usual suspects, Analytics, Loggers and go on.

Have a look also at this thread: App is crashing on only iOS 13 in the background mode

like image 179
Mihai Georgescu Avatar answered Sep 28 '22 20:09

Mihai Georgescu