Repository navigation
Description
What happened?
Summary
On macOS, switching to a plain AC-3 audio track with selectAudioTrack(index:) kills the session. The reload's rebuilt master (with ac-3 in CODECS) is rejected by AVPlayer with -11868, the engine signals its media-playlist fallback, but the media mount never happens and the session ends at .error("Cannot open"). The initial load of the same source goes through the same rejection shape and recovers, so the hole is specific to the reload path. The switch itself follows the documented contract (index is TrackInfo.id, called on the main actor, session on the .loopback route), and the same stream with its default E-AC-3 track and an AAC 2.0 track on another title switches correctly.
Steps to reproduce
- Load the source; it plays with
audioDelivery=streamCopyon the default E-AC-3 track. (One-11868master rejection on the initial load too — the DV P8.1 supplemental with no assertion — which the engine recovers with the in-place media-playlist fallback, costing ~0.4 s.) selectAudioTrack(index: 2)(the AC-3 track'sTrackInfo.id).
AetherEngine version or commit SHA
AetherEngine 7.44.0 (FFmpegBuild 3.9.0), host drives the engine through AetherPlayerView on the native loopback route
Host app
Custom / my own integration
Platform
macOS
OS version
macOS 27.0.1 (26A434)
Device / chip
Mac14,9 (Apple M2 Pro MacBook Pro)
Playback path
Native AVPlayer
Source media (for playback bugs)
From the engine's probe (authoritative for this file; ffprobe was not at hand):
- Container: Matroska (MKV), 29.1 GB, 8700.7 s, avg 26.8 Mb/s (peak segment 49.3 Mb/s)
- Video: HEVC Main 10 (codecpar codec=173, profile=2, level=150), 3832x1600, 23.976 fps, BT.2020 primaries / PQ transfer / BT.2020nc matrix, full range
- HDR: HDR10 base + Dolby Vision Profile 8.1 (
dvh1.08.06/db1p; DV source profile=8 compat=1 level=6 rpu=1 el=0 bl=1) - Audio: track 1 E-AC-3 5.1 (default,
ec-3); track 2 AC-3 5.1 (ac-3, the one being switched to) - Load options at the time:
dolbyVisionHandling: .baseLayerOnly(no DV assertion),progressiveSegmentDelivery: true,audioBridgeMode: .surroundCompat(untouched), preferredAudioLanguages/SubtitleLanguages unset
Error codes / log lines
[AetherEngine] reload begin: audioStream=2 resumeAt=981.10s
[AetherEngine] reload: stopInternal done (149ms)
[AetherEngine] reload: loadNative enter audio=2
[HLSVideoEngine] audio: override accepted, sourceStreamIndex=2 (auto would have picked 1)
[HLSVideoEngine] audio: codec=ac3 → stream-copy as `ac-3` (fallback duration=32 in audioTb 1/1000)
[mp4 @ ...] [warning] track 1: codec frame size is not set
[HLSVideoEngine] prepared: codec=hvc1.2.4.H150.b0,ac-3 supplemental=dvh1.08.06/db1p resolution=3832x1600 fps=23.976 range=PQ DV=profile81
[NativeAVPlayerHost] #3 load url=http://127.0.0.1:58319/<redacted>/master.m3u8 startPos=981.10s
[NativeAVPlayerHost] #3 asset.load(isPlayable) ok value=true
[NativeAVPlayerHost] #3 asset.load(duration) ok seconds=8700.704
[NativeAVPlayerHost] #3 item.status=failed err=AVFoundationErrorDomain/-11868 'Cannot open'
[NativeAVPlayerHost] #3 item.error.underlying=CoreMediaErrorDomain/-17223 'The operation couldn’t be completed. (CoreMediaErrorDomain error -17223.)'
[NativeAVPlayerHost] #3 startup .failed is a master rejection (code=-11868); signalling engine for media fallback instead of surfacing
[NativeAVPlayerHost] #3 errorLog dump: <nil>
[NativeAVPlayerHost] #3 accessLog dump: 0 events
→ session ends at .error("Cannot open"); no GET /media.m3u8 (the recovering mount) ever follows
The two masters the engine served (trimmed):
# initial load (plays):
#EXT-X-STREAM-INF:...,CODECS="hvc1.2.4.H150.b0,ec-3",RESOLUTION=3832x1600,FRAME-RATE=23.976,VIDEO-RANGE=PQ,...
# reload after the AC-3 pick (rejected):
#EXT-X-STREAM-INF:...,CODECS="hvc1.2.4.H150.b0,ac-3",RESOLUTION=3832x1600,FRAME-RATE=23.976,VIDEO-RANGE=PQ,...
On the initial load the request sequence is `GET /master.m3u8 → -11868 → GET /media.m3u8 → GET /init.mp4 → GET /segN.mp4` and playback succeeds. On the reload it stops at the master.
Anything else
Should the reload path recover from a master rejection the way the initial load does? The rejection is classified and signalled (startup .failed is a master rejection ... signalling engine for media fallback), but on the reload the fallback never mounts. If it is meant to mount, this is the bug.
Notes
- A stream with a second AAC 2.0 track (
CODECS="hvc1...,mp4a.40.2") switches fine on the same host and route, so the reload machinery itself is healthy; the failure tracks the AC-3 codec. - Full engine logs (both the failing reload and the working initial load) are available on request; URLs elided here because they carry provider credentials.
Activity
adityabakare commentedon Oct 22, 2026
Found the root cause and a fix.
The master→media fallback is gated by masterFallbackUsed, a per-session "fall back at most once" latch (AetherEngine.swift:2649). That latch was reset only in load()'s prologue (loadSession, line 4322). The session-preserving rebuilds — reloadWithAudioOverride (what selectAudioTrack calls) and reloadAtCurrentPosition — call stopInternal() and then go straight to loadNative(), never passing through load()'s prologue, so the latch is never reset for them.
The sequence on this source:
The -11868 on the reload is the same display rejection the initial load paid (a PQ/HDR master to a panel that refuses it here) — it's just that the initial load's recovery had already spent the latch the reload needed. An AAC 2.0 track switches fine because its rejection isn't a display rejection (-11868/-11848), so the latch is never spent on it.
The fix is one line in stopInternal (the shared teardown every rebuild passes through), so the reload's fresh master gets its own single-shot:
masterFallbackUsed = false
This is safe for the in-place stage-2 item recovery (reloadStalledConsumerItem), which uses swapItem — not stopInternal — and therefore keeps the latch, preserving the documented "the fallback reads the placement of the item it replaces" behavior.
fix(native): reset the master-fallback single-shot across session-pre…
Merge #852: reset the master-fallback single-shot across session-pres…
chore(native): file the #849 latch reset under Unreleased and under i…
superuser404notfound commentedon Oct 24, 2026
Fixed by #852 (merged as 83fcb1f): the master-fallback single-shot now resets in
stopInternal, so the session an audio-track switch orreloadAtCurrentPositionbuilds gets its own fallback after a master rejection. It ships with the next AetherEngine release; leaving this open until the switch to the AC-3 track is confirmed on that build.fix(native): an audio switch keeps the media playlist its session fel…
Merge fix/audio-switch-keeps-media-849: an audio switch keeps the med…
superuser404notfound commentedon Oct 24, 2026
Follow-up on main (0f080f8): an audio switch now keeps the media playlist when the display already refused this session's HDR master, so switching to the AC-3 track no longer rebuilds a master that gets refused again and pays the fallback a second time. The rebuilt session inherits that, so later switches stay on the media playlist too.
selectTitleandreloadAtCurrentPositionstill route afresh. Ships with the same next release as #852.fix(native): a refused HDR master does not latch the panel refusal on…
Merge fix/builtin-panel-refusal-no-latch: a refused HDR master does n…
superuser404notfound commentedon Oct 24, 2026
One more change on main (def48fe), plus a question for the retest.
On iOS and macOS a refused HDR master no longer latches the process-wide panel refusal. On those platforms the playlist routing reads the display's HDR eligibility, so the latch never changed anything there except a log line claiming later HDR titles went media-direct. Each refused item still falls back to the media playlist on its own.
I could not reproduce the
-11868here. Withaetherctl play --surfaceon a MacBook Air M1 (built-in SDR panel, HDR-eligible), a source shaped like yours (Dolby Vision P8.1, E-AC-3 track 1, AC-3 track 2) played its master with and without--dv-base-layer, and switching to AC-3 went through on both. A High-tier (hvc1.2.4.H150) 3832x1600 PQ master with the same switch did too.Question for the retest: your reload log shows
supplemental=dvh1.08.06/db1p. WithdolbyVisionHandling: .baseLayerOnly, the engine leaves outSUPPLEMENTAL-CODECSand that log shows none. Could you check whichdolbyVisionHandlingthe session actually ran with? Could you also attach the initial load's[DisplayCriteria]/[DisplayCapabilities]lines around its-11868? Those would tell whether the XDR panel refuses the DV supplemental or the PQ master itself.superuser404notfound commentedon Oct 26, 2026
Released in 7.48.0 (263dc11). Leaving this open for the retest.