Swift Concurrency
The assumeIsolated crash in a BGTask expirationHandler, and why Swift 6 didn't warn
iOS calls a background task's expiration handler on a queue of its own, not the one you registered. One MainActor.assumeIsolated in that closure took down a TestFlight build, and the compiler had nothing to say about it.
Two crash reports came back from TestFlight build 0.7 (10) of ClamNotes ten minutes apart, from an iPhone 15 Pro Max and an iPad Pro. Same exception on both: EXC_BREAKPOINT (SIGTRAP), crashed thread at _dispatch_assert_queue_fail, one frame above it MainActor.assumeIsolated, and above that a closure I had written as the expiration handler of a background task. If you got here by searching for Incorrect actor executor assumption, it's the same bug under a different signature; I'll show where each one comes from.
This post is the whole story: what the crash report says, why assumeIsolated traps instead of quietly doing the right thing, why neither the Swift 5 nor the Swift 6 language mode warned me, the fix that shipped in 0.7 (11) the same night, and how I reproduced it in the Simulator, where background tasks don't exist.