The expirationHandler on BGProcessingTask is a () -> Void closure. It provides no information about why it was called.
In my testing, all of the following trigger the same handler:
- Time expiration
- Resource pressure (CPU, memory, battery)
- Not reporting progress
- User tapping "Stop" on the Live Activity
There is no way for the app to tell these apart.
Questions:
Q1. Is there an official, complete list of all conditions that trigger expirationHandler? The documentation only mentions "time expires."
Q2. What is the specific time limit before timeout? If it varies by device state, what are the conditions?
Q3. A way to distinguish the reason is needed. "User stop" and "system expiration" require completely different handling. Currently this is impossible.
Environment: iOS 26, physical device
Q1. Is there an official, complete list of all conditions that trigger expirationHandler? The documentation only mentions "time expires."
No, but the primary causes are user cancellation and failure to report progress. Theoretically, resource pressure could cause it; however, in practice, I think the system typically ends up killing your app instead[1].
Q2. What is the specific time limit before timeout? If it varies by device state, what are the conditions?
There isn't any specific time limit. I've never worked out what the "absolute" maximum (defined by the progress reporting requirement) is, but that limit would be high enough that it's not really a constraint.
Q3. A way to distinguish the reason is needed. "User stop" and "system expiration" require completely different handling. Currently, this is impossible.
Yes, this is definitely an issue with the API. Please file an enhancement request asking for this, then post the bug number back here.
[1] The issue here is similar to (one of…) the reason why memory pressure warnings are relatively rare. In practice, sudden memory resource “spikes” are what typically lead to these issues and those happen faster than the system could notify you.
__
Kevin Elliott
DTS Engineer, CoreOS/Hardware