Repository navigation
fix(airplay): every session-preserving rebuild holds the external-playback edge (#227 round 2) - #562
Merged
superuser404notfound merged 1 commit intoSep 19, 2026
Conversation
…yback edge (#227 round 2) #227 put the edge hold on one rebuild, `reloadAtCurrentPosition`'s URL branch. The other three went without it: the audio pick, the disc-title pick, and that same function's custom-source branch, all of which rebuild through `reloadWithAudioOverride`. Every rebuild tears down the item the external-playback KVO watches, so every one of them raises a `false` edge that describes the teardown and not the route. Measured on an AirPlay route, device log 2026-09-19 (Sodalite#156). The asymmetry is visible in the log itself: no "holding the edge" line during the audio rebuild, two of them during the reloadAtCurrentPosition that followed it. The unheld `false` cleared `airPlayActive` before `loadNative` read it, so the pick rebuilt the session on 127.0.0.1, which a receiver cannot reach. The Apple TV never requested that port at all. The receiver then re-engaged and the true edge paid for a SECOND full rebuild to get back onto the LAN URL: one audio pick, two session rebuilds, the first dead on arrival. The hold is now raised in the shared funnel, so the three rebuilds that go through it inherit it. Both sites restore the flag rather than clearing it, and only the outermost rebuild reconciles: a nested one that reconciled would start a reload inside the teardown of the rebuild still running, which is #227's loop reached from the inside instead of from the KVO. The invariant is structural, so the test is too, the shape Issue541ReloadCarriesHDRRouteTests already uses to pin a reload call site. Both new source-level tests were checked against the pre-fix sources and are red there. Not covered by this: the reporter also saw a title restart at its head after a pick, which is no longer reproducible. It fits a race this stacked second rebuild opens (`positionForSessionRebuild` returns the parked position only while state is .loading), and removing the second rebuild removes the window, but that is reasoning, not a measurement. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F
superuser404notfound
deleted the
fix/hold-airplay-edge-on-every-rebuild
branch
September 19, 2026 14:25
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.
Found while working Sodalite#156 (the iOS remote view). Reported by Vincent as "switching the audio language during AirPlay reconnects and restarts the title"; the reconnect half is measured and fixed here.
The asymmetry
#227established that an external-playback edge arriving mid-rebuild describes the teardown, not the route, and must be held until the rebuilt item settles. That hold was put on exactly one rebuild,reloadAtCurrentPosition's URL branch. Three others go without it, all throughreloadWithAudioOverride:selectAudioTrack)selectTitle)reloadAtCurrentPosition's own custom-source branch, which returns before the flag is setWhat it costs, from the device log (2026-09-19, iPhone 17 Pro to Apple TV)
The log shows the two paths side by side. The audio rebuild:
and the
reloadAtCurrentPositionit triggered:The unheld
falseclearedairPlayActivebeforeloadNativeread it, so the pick rebuilt the session on127.0.0.1:64632, an address a receiver cannot reach. The Apple TV (10.20.30.12) never requested that port at all; it appears only against the second session on64638. One audio pick, two full session rebuilds, the first dead on arrival for the receiver.The fix
The hold moves into the shared funnel, so all three rebuilds inherit it. Both sites now restore the flag instead of clearing it, and only the outermost rebuild reconciles: a nested one that reconciled would start a reload inside the teardown of the rebuild still running, which is
#227's loop reached from the inside rather than from the KVO.Tests
The invariant is structural (WHERE the hold is raised), so the test is structural too, the shape
Issue541ReloadCarriesHDRRouteTestsalready uses to pin a reload call site. Both source-level tests were run against the pre-fix sources first and are red there:Full suite, both runners: swift-testing 3104 tests in 423 suites, XCTest 17 tests, 0 failures.
Not covered
The reporter also saw a title restart at its head after a pick. That is no longer reproducible, which fits a race rather than a deterministic fault:
positionForSessionRebuildreturns the parked position only whilestate == .loading, and the stacked second rebuild this fix removes is what opens that window. Removing the window makes it likely to be gone, but that is reasoning, not a measurement, and it is not claimed as fixed.🤖 Generated with Claude Code
https://claude.ai/code/session_015PM3xUJB6ZQyqnmGK1fp6F