Skip to content

fix(native): reset the master-fallback single-shot across session-preserving reloads - #852

Merged
superuser404notfound merged 3 commits into
superuser404notfound:mainfrom
adityabakare:ac3-fix
Oct 24, 2026
Merged

superuser404notfound merged 3 commits into
superuser404notfound:mainfrom
adityabakare:ac3-fix

Conversation

@adityabakare

@adityabakare adityabakare commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A session-preserving reload (audio-track switch, reloadAtCurrentPosition) recovers from its own master rejection again. The reactive master→media fallback's single-shot latch was reset only in load()'s prologue, which the reload paths never reach, so a fallback spent on the outgoing session's master leaked into the reload and turned the reload's own rejection into a terminal .masterPlaylistRejected.

Refs #849

What changed

  • Sources/AetherEngine/AetherEngine.swift — reset masterFallbackUsed in stopInternal, the shared teardown every session-preserving rebuild passes through. The in-place stage-2 recovery is unaffected: it uses swapItem, not stopInternal, so it keeps the latch (preserving "the fallback reads the placement of the item it replaces").

  • Tests/AetherEngineTests/MasterFallbackResetTests.swift — new coverage: the latch resets across the shared teardown and re-admits the new session's -11868.

  • CHANGELOG.md — entry under [Unreleased].

  • Device / OS: Mac14,9 (Apple M2 Pro), macOS 27.0.1 (26A434), built-in Liquid Retina XDR; native .loopback route via aetherctl.

  • Source media: MKV, 29 GB; HEVC Main 10 3832x1600 @ 23.976, BT.2020 / PQ, HDR10 + Dolby Vision P8.1 (dvh1.08.06/db1p); audio track 1 E-AC-3 5.1 (default), track 2 AC-3 5.1. Loaded with dolbyVisionHandling: .baseLayerOnly, progressiveSegmentDelivery: true, audioBridgeMode: .surroundCompat.

  • Result:

    • Initial load with the AC-3 track (CODECS="hvc1…,ac-3") plays clean — confirms AVPlayer accepts ac-3 in an HLS master on macOS, so AC-3 stays stream-copy (the packaging is not the bug; the track 1: codec frame size is not set warning appears in the working baseline too, and the dac3 box is correctly packet-derived via the moov-prime).
    • The failing direction — initial E-AC-3 (ec-3), then selectAudioTrack to AC-3 — previously surfaced .masterPlaylistRejected("Cannot open") with no GET /media.m3u8. With the latch reset in stopInternal, the reload recovers: reload begin: audioStream=… → reload: state=.playing, no error.
    • On a display that accepts the master the rejection never fires; on one that rejects it (the reporter's), the reload now mounts the media playlist instead of dying.
  • Suite: swift test — 4785 tests pass, including the new MasterFallbackResetTests and the unchanged MasterFallbackPositionTests / StaleSessionCallbackTests.

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 - NO Public API Change

adityabakare and others added 3 commits October 22, 2026 15:12
…serving reloads (superuser404notfound#849)

The reactive master→media fallback's single-shot latch (masterFallbackUsed)
reset only in load()'s prologue, which the session-preserving rebuilds
(reloadWithAudioOverride, reloadAtCurrentPosition) never pass through.
A fallback spent on the outgoing session's master — a DV P8.1 source's
one -11868 + media fallback at mount — leaked into the reload, whose own
master rejection then surfaced .masterPlaylistRejected ("Cannot open")
instead of falling back to the media playlist. Reset the latch in
stopInternal, the shared teardown every rebuild passes through, so the
reload's fresh master gets its own single-shot. The in-place stage-2
recovery keeps the latch: it uses swapItem, not stopInternal.
@superuser404notfound
superuser404notfound merged commit 83fcb1f into superuser404notfound:main Oct 24, 2026
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged in 83fcb1f, thanks @adityabakare, that is a clean find: the single-shot was correct per session, it just was not reset for the sessions a reload builds. The diagnosis and the macOS reproduction made this a quick merge.

One follow-up on main (a71c6b1): the CHANGELOG entry had landed inside the already released 7.46.0 section after the merge, so it moved to [Unreleased]; the code comment and the test suite now name #849 instead of #98 (the issue the fallback was originally built for).

The fix ships with the next AetherEngine release. #849 stays open until the AC-3 switch is confirmed on that release.

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