The problem isn’t that it isn’t running in the background, but rather whatever was running was blocking the main thread.
The 0x8badf00d
(“ate bad food”; lol) indicates that the watchdog process (that monitors for dead/blocked processes) killed your app, generally because you did something to block the main thread. If you avoid blocking the main thread, this error should go away. See Technical Note 2151: Understanding and Analyzing Application Crash Reports and search for 0x8badf00d
.
As it says:
The exception code 0x8badf00d
indicates that an application has been terminated by iOS because a watchdog timeout occurred. The application took too long to launch, terminate, or respond to system events. One common cause of this is doing synchronous networking on the main thread. Whatever operation is on Thread 0 needs to be moved to a background thread, or processed differently, so that it does not block the main thread.
They’re focusing on synchronous network requests, but it can be anything that blocked the main thread for too long, whether a slow synchronous process or a deadlock or whatever. You should look at the stack trace for thread 0 and see if you can identify what blocked the main thread. There’s not enough here for us to diagnose it, though.
Common culprits include synchronous network calls, synchronous GCD calls, inappropriate use of semaphores, locks, or dispatch group “wait” calls, deadlocks, etc.