Skip to content

fix(audio): serialize track rebuilds and preserve transport intent - #711

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
yucelokan:codex/serialized-audio-selection
Oct 7, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
yucelokan:codex/serialized-audio-selection

Conversation

@yucelokan

Copy link
Copy Markdown
Contributor

Summary

Coalesce rapid audio selections into one rebuild at a time and preserve the latest play/pause command across asynchronous reopen. Invalidate pending selections on stop or a new load.

What changed

  • Fence queued audio work with its own epoch and the existing load generation.
  • Suppress cancellation/supersession errors and preserve transport changes received during I/O.
  • Retain the current native item during ordinary audio handover; media-services resets still discard it.
  • Add ownership regressions and document the non-gapless handover contract.

Test plan

  • Device / OS: Apple M1 Pro Mac, macOS 27.0.1; Xcode 27.0 (27A266a), Swift 6.4.
  • Source media: controlled audio-selection state plus the existing embedded MP4/HDR10+ fixture and controlled readers used by reload/cancellation suites; no claim of a new multitrack device playback run.
  • Result: swift test --jobs 4 --filter 'AudioSelectionOwnershipTests|Issue464|Issue357|CancellableLoadTests|PublicAPIDocumentationTests|DocumentedConstantsTests' passed: 24 XCTest cases and 97 Swift Testing cases. swift build --jobs 4, documentation links and git diff --check pass.
  • Production use: this behavior already ships in WUW's App Store release, with physical iPhone and Apple TV use. The isolated PR revision is based on upstream 7.28.3; the reproducible checks above describe this revision rather than claiming a new device run.

Checklist

  • CHANGELOG.md updated
  • Commit messages follow Conventional Commits (feat(...), fix(...), chore(...))
  • The fix lives in the engine, not in a host-side workaround
  • Public API changes are intentional and documented

superuser404notfound pushed a commit that referenced this pull request Oct 7, 2026
…rebuild

#711 documented the new contract under "Public but not host API" while the
Audio table still promised 0.5 to 1 s of black on every switch. The row now
carries the contract itself: native handover keeps the old item mounted,
rapid picks coalesce, stop/load drop queued work, and a play/pause during the
rebuild decides its final transport.

Follow-up to #711.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound
superuser404notfound merged commit f231820 into superuser404notfound:main Oct 7, 2026
@superuser404notfound

Copy link
Copy Markdown
Owner

Thanks, merged. Coalescing the picks fixes a real gap: a second pick during a rebuild used to race the first one's generation check. One follow-up landed on top (b64ff7e): the API reference now states the new contract in the selectAudioTrack(index:) row of the Audio table, which still promised 0.5 to 1 s of black on every switch, rather than in a separate section under "Public but not host API". Native item retention will get a device round on our side before the next release.

superuser404notfound pushed a commit that referenced this pull request Oct 7, 2026
…t comes back

#711 parked the transport for an audio pick in a field of its own, beside
transportIntentUnderReconstruction (AE#464 round 3), so a press during a
disc-title switch, reloadAtCurrentPosition or an engine-raised rebuild was
still lost: the rebuild came back in the state it started from. play() and
pause() now write the existing field while sessionPreservingReloadInFlight
holds (not while .loading, which play() itself leaves), reloadWithAudioOverride
settles from it, and the URL branch of reloadAtCurrentPosition replays it after
load() returns. audioSelectionTransportIntent is gone.

Covered end to end on both branches: a pause during an audio rebuild and during
a URL reload holds, a play during a custom-source reload holds, and a press
outside a rebuild parks nothing. All four fail without the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
@superuser404notfound

Copy link
Copy Markdown
Owner

Released in 7.29.0. Two things grew out of this one in the same release: a play or pause during the rebuild is now honoured for every session rebuild (play()/pause() write transportIntentUnderReconstruction, which replaced the audio-only field), and the item swap of an audio switch holds the outgoing picture instead of flashing black. A host that renders the native path through AVKit binds an AetherStillView for that; with an AetherPlayerView bound nothing changes on the host side.

ijuniorfu pushed a commit to ijuniorfu/AetherEngine that referenced this pull request Oct 8, 2026
superuser404notfound#711 keeps the outgoing item mounted while the source reopens, but
replaceCurrentItem still drops the AVPlayerLayer to black until the new
item decodes its first frame, and on device that read as a flash on every
switch. The rebuild now reads the frame on screen from the paused item
(NativeAVPlayerHost.captureDisplayedFrame, ~20 ms paused; a playing item
needs ~300 ms before a fresh output sees anything, which is why it reads
after the pause) and lays it over the hosted layer on the bound
AetherPlayerView as a one-sample AVSampleBufferDisplayLayer, so an HDR
frame goes through its colour attachments as the software path's frames
do. It comes down when the next host session reports isVideoReadyForDisplay,
on stop, load, a failed or superseded rebuild, unbind, or after 8 s.
Skipped for Dolby Vision (the output vends the base layer, which has no
displayable colour of its own for Profile 5), PiP and external playback.

Covered on a generated 4 s H.264 + AAC file: a playing and a paused item
hand over a frame, an audio rebuild holds the picture and releases it on
the next item's first frame (red with the hold disabled), stop takes it
down, and the skip rules.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants