Fix Swift 6 async let actor isolation crash#67
Fix Swift 6 async let actor isolation crash#67NickTrienens2025 wants to merge 1 commit intochristopherkarani:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93ece0a935
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| let surrogateMapTask: [UInt64: UInt64] = shouldPrefetchSurrogates | ||
| ? try await wax.surrogateFrameIds(for: sourceFrameIds) | ||
| : [:] | ||
| async let sourceFrameMetasTask: [UInt64: FrameMeta] = shouldPrefetchSurrogates | ||
| ? wax.frameMetas(frameIds: sourceFrameIds) | ||
| let sourceFrameMetasTask: [UInt64: FrameMeta] = shouldPrefetchSurrogates | ||
| ? try await wax.frameMetas(frameIds: sourceFrameIds) |
There was a problem hiding this comment.
Avoid blocking expansion on surrogate prefetch calls
These two immediate awaits run before expansion starts, so every denseCached request now pays for surrogateFrameIds + frameMetas on the critical path even when surrogate assembly is later skipped (for example, when expansion consumes the token budget). In the previous version this work was overlapped with expansion via async let; here it is fully serialized, which introduces avoidable latency in the common path. Keep the async-let workaround, but move these awaits into the surrogate phase (after expansion determines surrogates are still needed) to avoid front-loading this I/O.
Useful? React with 👍 / 👎.
Replaces async let calls to actor-isolated methods with sequential awaits to fix a known compiler bug on macOS ARM64 that causes a swift_task_dealloc heap corruption. The async let task lowering in Swift 6 occasionally triggers a double-free of the task context when capturing self on an actor. Moving to sequential await avoids the compiler miscompilation.