The AI Coding Agent Passed the Build. The App Still Crashed on Launch
Description and use
AI‑generated code compiled and passed tests but crashed at runtime due to actor isolation violations in a Core Audio callback. Moving the callback creation to a nonisolated context and marking it @Sendable fixed the issue, and a 60‑second simulator test now guards against similar failures.
Problem
An AI‑generated Swift audio feature compiled and passed tests but crashed at runtime due to actor isolation violations in a Core Audio callback.
Outcome
The refactor resolved the runtime crash by ensuring the audio callback ran on the correct thread and met Swift 6's actor isolation rules. A simple 60‑second smoke test now guards against similar runtime boundary failures.
Workflow
- 1. Use Claude to generate the adaptive audio feature code.
- 2. Build the app and run unit tests.
- 3. Observe that the app crashes on launch with SIGTRAP when the audio engine calls the render block.
- 4. Identify that the closure was created inside a @MainActor context, causing a runtime actor isolation trap.
- 5. Refactor by moving the callback creation to a nonisolated static function and marking the closure @Sendable.
- 6. Add a runtime smoke test: launch the app in the simulator, exercise the callback path, keep it running for 60 seconds, then install or ship the build.
Evidence
The code compiled. The tests passed. The app installed. Then it crashed as soon as the audio engine called its render block.
The problem was where the closure had been created. The audio class was @MainActor, so Swift 6 treated the render closure as main-actor isolated too.
That closure does not run on the main actor. Core Audio calls it from a real-time audio thread. The compiler accepted the handoff, but the runtime actor check trapped the first time Core Audio invoked it.
The fix was small: form the callback outside the actor-isolated context and make the threading contract explicit.
Now any AI-assisted change that hands a closure to a system framework gets a tiny runtime gate: launch the app in the simulator, exercise the callback path, leave it running for 60 seconds, only then install or ship the build.
- Record date: 2026-10-24T13:26:31.184Z