Repository navigation
fix(audio): the tap continuation's weak capture sat on the wrong closure - #350
Merged
Merged
Conversation
Surfaced by @jihongboo's Xcode 27 beta build log on #313, unrelated to the SDK isolation thread it came from: ImplicitStrongCapture flags that the `[weak self]` on the inner Task was decorative. The outer onTermination closure captured `self` strongly anyway, so the controller's own continuation retained the controller back. Not a leak today, because every path (removeAudioTap, load, stop) releases the controller through `teardown()`, which finishes the continuation and drops the handler. What it cost was the guarantee the annotation claimed: a path that dropped the controller without tearing down would have kept the reader running rather than stopping it, and the code read as if it could not. Moving the capture to the outer closure makes the declared intent the actual one. `teardown()` is idempotent, so a nil `self` when termination lands after teardown is a no-op. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AudioTapController.makeStreamwrote[weak self]on theTaskinsidecont.onTermination. The outer closure capturedselfstrongly regardless, so the continuation this controller owns retained the controller back. Swift 6.3 flags it as#ImplicitStrongCapture; it showed up in @jihongboo's Xcode 27 beta build log on #313 and is unrelated to the SDK isolation thread there.Not a leak in the shipped paths:
removeAudioTap,loadandstopall go throughteardown(), which finishes the continuation and drops the handler. What the misplaced capture cost was the guarantee it appeared to give, a path that released the controller without tearing down would have kept the reader running instead of stopping it.Moving the capture to the outer closure makes the declared intent the real one.
teardown()is idempotent, so termination landing after teardown with a nilselfis a no-op.swift buildclean,swift test --filter AudioTap37/37.🤖 Generated with Claude Code
https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE