Get the latest tech news

Watch Out for Counterintuitive Implicit Actor-Isolation


Beware @unchecked Sendable, or Watch Out for Counterintuitive Implicit Actor-Isolation I ran into some unexpected runtime crashes recently while testing an app on iOS 18 compiled under Swift 6 language mode, and the root causes ended up being the perils of using @unchecked Sendable in combination with some counterintuitive compiler behavior with implicit actor isolation. Rather than start at the end, I’ll walk you through how I introduced the crash, and then what I did to resolve it.

What happened next led me down a path to some code that (A) compiled without warnings or errors but (B) crashed hard at runtime due to implicit actor isolation assertion failures. Pinky swears, documentation, peer review, and long stretches of production battle-hardening should be a sufficient counter to any gripes that the Swift 6 runtime may have about our desire to ignore actor isolation. What’s happening here is the compiler is reasoning “this closure is not Sendable so it couldn’t possibly change isolation from where it was formed and therefore its body must be MainActor too” but your unchecked type allows this invariant to be violated.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Isolation

Isolation

Related news:

News photo

James Webb Telescope discovers some quasars that seem to exist in isolation

News photo

Reports show some Canada euthanasia deaths driven by social reasons

News photo

It’s a spooky season miracle — Alien: Isolation is getting a sequel