Thanks for the post.
It seems like the app is running in the background and gets terminated after the timeout.
Thread 3 name: Dispatch queue: com.apple.root.background-qos
Thread 3 Crashed:
0 libsystem_kernel.dylib 0x00000001f68ee0dc __pthread_kill + 8
1 libsystem_pthread.dylib 0x00000001f6967094 pthread_kill$VARIANT$mp + 380
2 libsystem_c.dylib 0x00000001f6846ea8 abort + 140
3 libc++abi.dylib 0x00000001f5f13788 __cxa_bad_cast + 0
4 libc++abi.dylib 0x00000001f5f13934 default_unexpected_handler+ 6452 () + 0
5 libobjc.A.dylib 0x00000001f5f2ae00 _objc_terminate+ 24064 () + 124
6 libc++abi.dylib 0x00000001f5f1f838 std::__terminate(void (*)+ 55352 ()) + 16
7 libc++abi.dylib 0x00000001f5f1f8c4 std::terminate+ 55492 () + 84
8 libdispatch.dylib 0x00000001f67907e8 _dispatch_client_callout + 36
9 libdispatch.dylib 0x00000001f6741164 _dispatch_root_queue_drain + 680
10 libdispatch.dylib 0x00000001f67418d4 _dispatch_worker_thread2 + 128
11 libsystem_pthread.dylib 0x00000001f69711b4 _pthread_wqthread + 464
12 libsystem_pthread.dylib 0x00000001f6973cd4 start_wqthread + 4
- The crash occurs on Thread 3, which is running in the background (
Dispatch queue: com.apple.root.background-qos
). - The
pthread_kill
function is being called, which forcefully terminates the thread. - This termination leads to a series of unwind calls, ultimately resulting in the
_objc_terminate
function, indicating that the entire app is being terminated.
Possible Reason for Termination:
The app is likely being terminated after the specified background execution time limit has been exceeded. iOS has strict guidelines for background app usage to preserve battery life and system resources.
Recommendation:
To prevent background terminations, you should optimize your app's background tasks to complete within the allowed time limit. Here are some general tips:
- Reduce Background Activity: Minimize the number of tasks your app performs in the background.
- Use Background Execution Modes Appropriately: Understand and use the correct background execution modes provided by iOS, such as
.location
, .fetch
, .audio
, etc. - Background Fetch Optimization: If you use
.fetch
mode, ensure your app fetches data efficiently and minimizes the time it takes to complete. - Inspect Background Task Logs: Use Xcode's "Debug Navigator" to inspect your app's background task logs and identify any tasks that may be taking too long.
Additional Resource:
Every iOS version may handle background timeouts a little differently.
For more detailed information on reducing background terminations and optimizing background performance, refer to the documentation:
https://developer.apple.com/documentation/xcode/reduce-terminations-in-your-app#Background-termination-reasons