I have a fairly complicated application with lots of Pods/modules doing network requests and possibly background activities.
Recently, we started noticing the app crashing in the background due to background duration expiry. As this particular scenario is not unit tested, its hard to find the exact culprit. It could have been introduced months ago.
<BKNewProcess: 0x100331a00; com.app.app; pid: 392; hostpid: -1> has active assertions beyond permitted time:
{(
<BKProcessAssertion: 0x100222ed0> id: 392-AA97D7E3-7BE3-4A43-BC88-A5601EBD76D6 name: Called by UIKit, from <redacted> process: <BKNewProcess: 0x100331a00; com.app.app; pid: 392; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:392 preventSuspend preventIdleSleep preventSuspendOnSleep ,
<BKProcessAssertion: 0x100337b40> id: 392-1572EDBD-EE61-4939-A315-6CD82DEF3354 name: Called by UIKit, from <redacted> process: <BKNewProcess: 0x100331a00; com.app.app; pid: 392; hostpid: -1> permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:392 preventSuspend preventIdleSleep preventSuspendOnSleep
)}
The question is, is there a way to debug which tasks exist in the background (e.g. enumerating all background tasks) or say a way to kill all background tasks when entering background? How would you go about debugging this issue?