Repository navigation
Description
Summary
When wireless AirPlay engages or ends, the engine reloads itself to move the
loopback playlist onto the device's LAN IP and back
(handleExternalPlaybackChange → reloadAtCurrentPosition(), the #86 path).
That reload is a full load(), and load()'s stopInternal wipes three
pieces of session state the host set up — none of which the engine restores:
- Mid-session external subtitle registrations (
addExternalSubtitleTrack,
Select external subtitles to make them appear inengine.$subtitleTracks. #88).load()clearsexternalSubtitleRegistry/subtitleTracks/
nextExternalSubtitleOrdinaland re-registers only
LoadOptions.externalSubtitles. Every track the host added after load is
permanently gone — the host's menu still lists them, but selecting one
targets a synthetic id that no longer exists. - The active audio/subtitle selection. The reload re-runs
preferred-language auto-selection, which can silently override the user's
explicit picks (including subtitles they turned off). nativeSubtitleReapplyOrdinal. This is the sharpest edge: the host
reacts to AirPlay starting by callingsetNativeSubtitleRendering(true)
(per the documented contract), which sets the reapply ordinal — and the
engine's own AirPlay reload, triggered by the same KVO flip, then nils it
instopInternal. Net effect: the receiver renders no subtitles at
all, even for plain embedded text tracks, unless the host knows to
re-assert after an engine-initiated reload it never asked for.
Notably the #65/#93 stall-recovery path already handles this correctly for
in-place item swaps — after host.load(url:startPosition:inPlaceSwap: true)
it replays nativeSubtitleReapplyOrdinal onto the fresh item. The AirPlay
reload deserves the same courtesy, extended to all three items above.
Surfaced by a Prism beta report: streaming iOS → tvOS via AirPlay, "the
subtitle selection dropdown is tripping out" (the wipe/republish churn
re-rendering an open menu) "and no data seems to be sent to the AirPlay
server side" (items 2 and 3, plus overlay-only mid-session tracks).
Repro
- Host app:
load()a stream withprepareNativeSubtitles = true, an
embedded text subtitle track active, and one track added mid-session via
addExternalSubtitleTrack. - Start playback, then AirPlay the video to an Apple TV (wireless — the
wired-HDMI branch doesn't reload and is unaffected). - Call
setNativeSubtitleRendering(true)on the external-playback flip (as
documented for PiP/AirPlay). - Observe:
[AirPlay] external playback active (wireless) -> LAN media reload, then:subtitleTracksrepublishes without the mid-session external track;activeSubtitleTrackIndexis nil (or the preferred-language auto-pick,
not the user's track);- no legible rendition is selected on the receiver — the Sodalite#38
force-deselect loop runs becausenativeSubtitleReapplyOrdinalis nil
again.
Asks
- Carry session state across engine-initiated reloads (AirPlay LAN swap
today; anything else that callsreloadAtCurrentPosition()internally):
re-register mid-session external tracks (preserving their synthetic ids if
possible), re-select the previously active audio/subtitle tracks instead
of re-running auto-selection, and replaynativeSubtitleReapplyOrdinal
the way the Presented frame drifts ~6 s ahead of currentTime/sourceTime after a rapid bidirectional seek burst (loopback-HLS native path) — frameAhead/producerShift/hostShift all report 0 #65 recovery already does. - (Feature, separable) Native-rendition eligibility for
addExternalSubtitleTrack: append a WebVTT rendition + cue store to the
live loopback master/media playlists so mid-session tracks can survive
PiP/AirPlay without the host performing a full re-declared reload. Today
the host's only route is a position-preservingload()with the track in
LoadOptions.externalSubtitles, which costs a visible rebuffer — during
AirPlay, exactly when the user is most likely to be adding subtitles.
Host-side workaround (shipping in Prism meanwhile)
On every isExternalPlaybackActive flip: freeze the host's track/selection
mirrors against the reload's transient wipe publishes, wait for the reload to
settle, re-addExternalSubtitleTrack the dropped tracks, re-apply the
session's picks, promote an overlay-only active pick via a re-declared reload,
and re-call setNativeSubtitleRendering. It works, but it's ~150 lines of
host code compensating for state the engine could preserve in one place.
Activity
fix(subtitles): carry subtitle session state across engine-initiated …
superuser404notfound commentedon Jul 21, 2026
Fixed in 5.17.1 (e0b6784). Excellent report, the three-item breakdown mapped exactly onto the code, and you are right that the #65 recovery already did this correctly for in-place swaps while the AirPlay reload restored nothing.
Ask 1 (session carryover) is implemented at the
reloadAtCurrentPositionlevel, so it covers the AirPlay LAN swap in both directions plus the background-return reopen:load()seeds it back id-exactly (removal gaps preserved, so later adds cannot collide with the session's id history). No more wipe/republish churn under an open menu.load()'s existingaudioSourceStreamIndexoverride (same mechanism the custom-source reload branch already used); the subtitle authority flag carries over, so the load-end preferred-language pass no longer runs against an explicit pick, including subtitles explicitly OFF.nativeSubtitleReapplyOrdinalis replayed the way the Presented frame drifts ~6 s ahead of currentTime/sourceTime after a rapid bidirectional seek burst (loopback-HLS native path) — frameAhead/producerShift/hostShift all report 0 #65 recovery does, recomputed against the rebuilt rendition table. On top of that there is a latch for the race you called out: the AirPlay flip triggers the engine reload and yoursetNativeSubtitleRendering(true)from the same KVO change, and if your call lands mid-reload (active track transiently nil) it used to be misread as a deselect. It is now deferred and applied once the reload has re-established the selection, so the receiver gets its legible rendition regardless of ordering.The audio-switch reload got the same ordinal replay (switching audio during PiP/AirPlay also stranded the receiver without subtitles), and an active external track now re-arms through its id there instead of collapsing to a one-shot sidecar URL.
Ask 2 (native-rendition eligibility for mid-session tracks) turns out to fall out of the carryover for the case that matters: the seed happens before the native rendition table is built, so mid-session tracks join the WebVTT renditions of the reloaded item. Since AirPlay entry IS an engine reload, your mid-session tracks become receiver-renderable at exactly that moment, at zero extra cost. The standalone form (promoting a track mid-item without any reload) is not implementable on AVPlayer: the master playlist is fetched once per item, so a rendition appended later never surfaces; an item swap is unavoidable, and the position-preserving re-declared
load()remains the route for that. If the rebuffer cost of that path bites in practice I would treat an engine-side "promote" convenience (engine-internal reload with the carryover applied) as a separate feature request.Your ~150-line host workaround should be fully removable on 5.17.1: no more transient wipe publishes to freeze against, dropped tracks to re-add, picks to re-apply, or rendering calls to re-assert. In the log you should see
#170 re-applying native subtitle ordinal=N after session-preserving reloadfollowing the[AirPlay] external playback active (wireless) -> LAN media reloadline.Covered by 19 new tests (
Issue170SessionCarryoverTests); full suite and multi-platform CI green. Please retest with your Prism beta setup (iOS to tvOS, embedded text track active plus a mid-session external) and report back; I will leave this open until you confirm.dlev02 commentedon Jul 21, 2026
Perfect, I'll get this shipped in the next beta release and report back what I find out (it may take a bit). As always, thanks!
Merge upstream/main (5.28.2) into fix/truehd-oom-backpressure
superuser404notfound commentedon Jul 31, 2026
Checking back on the session carryover. The fix shipped in 5.17.1 and the current release is 6.3.0, so whichever beta it rides now carries it either way.
No rush on the retest, this is only to keep the thread from going quiet. The confirmation that matters is the AirPlay LAN swap with an embedded text track active plus a mid-session external one, and the log line to look for is
#170 re-applying native subtitle ordinal=N after session-preserving reloadfollowing the[AirPlay] external playback active (wireless) -> LAN media reloadline. The ~150-line host workaround should be removable at that point.dlev02 commentedon Jul 31, 2026
Sorry for the long silence on this one. We're on 6.1.3 now, so the carryover has been riding along in the betas for a while, and I've heard back from the testers who originally hit this, nobody's reproduced the AirPlay case since. Subtitles keep working across the LAN swap in both directions, and the dropdown no longer trips out mid-session.
Good to close from my side. Thanks again for the thorough fix and for keeping the thread alive.
superuser404notfound commentedon Jul 31, 2026
Thanks for circling back, and no apology needed. A quiet beta cycle with the testers who originally hit this is a much better answer than a single synthetic retest, so that is exactly the confirmation I was after. Closing on it.
For anyone finding this thread later: the fix is the subtitle session carryover in 5.17.1 (e0b6784). From that release onward a session-preserving reload keeps the mid-session external tracks with their synthetic ids, re-selects the explicit audio and subtitle picks instead of re-deriving them (including subtitles explicitly off), and replays the native rendition ordinal, so the AirPlay LAN swap survives in both directions. Host-side scaffolding around that reload can go.
One boundary is still there on purpose: the native remote-HLS branch of
load()returns before the registry seed, so an m3u8 session reopened that way still loses mid-session external tracks. The AirPlay handler never routes through the reload for remote HLS, so it does not touch the case tested here, but if it ever surfaces on a background return it is worth its own issue.Thanks again for the report. The three-item breakdown mapped straight onto the code and made this an unusually easy one to fix.
fix(subtitles): the background teardown hands its selection to the re…
Revert "fix(subtitles): subtitles off deselects the native rendition" (…
fix(subtitles): the native rendition follows the host's pick in both …
fix(subtitles): subtitles off deselects the native rendition, not jus…
Merge upstream AetherEngine 7.13.0 into the Silo fork
feat(subtitles): markerOnly selection ticks a host-drawn track in AVK…