Repository navigation
Description
What happened?
Native WebVTT subtitles (LoadOptions.prepareNativeSubtitles) render correctly in a Picture in Picture window, but never appear on a wireless AirPlay receiver. Same session, same source, same selection call.
I think the two features are mutually exclusive by construction rather than mistimed, and the reason is visible in the code:
- Subtitle renditions are only ever declared in the master playlist.
HLSLocalServer.swift:64: "Native subtitle renditions (fix(native): apply externalMetadata on iOS too #15): one per text track, for the masterEXT-X-MEDIA:TYPE=SUBTITLEStags". - The wireless AirPlay path deliberately forces the media playlist.
AetherEngine.swift:3280-3281: "serve the loopback over the device's LAN IP (the receiver can't reach 127.0.0.1) AND to force the MEDIA playlist (AVPlayer rejects a DV/HDR MASTER playlist on an SDR receiver and won't auto-switch, DrHurt)".
A media playlist carries no EXT-X-MEDIA tags, so there is no legible group for setNativeSubtitleSelected(track:) to select against, and AVPlayer has nothing to render. That matches what I see: the call succeeds and changes nothing.
What I tried
Selecting on the route change, which fails, and then re-asserting the selection on every $isSessionReady edge so it lands after the LAN reload settles rather than before it. Neither shows subtitles on the receiver. That is consistent with the track not existing at all on that path, rather than being selected at the wrong moment.
I also briefly drove the selection from the AirPlay route without the re-assert. The failure mode there is worth recording: nothing on the receiver, then double-drawn subtitles once playback returned to the device, presumably the host overlay plus a native track that only became renderable after the return reload.
Why it matters
DV/HDR and subtitles are currently an either/or on wireless AirPlay, and the trade is made implicitly. A user who turns on subtitles and AirPlays gets no subtitles and no indication why.
Possible directions
I do not know this code well enough to say which is right, so these are questions rather than proposals:
- Could the AirPlay variant serve a master with a single SDR variant plus the subtitle renditions? That keeps
EXT-X-MEDIAavailable while avoiding the DV/HDR variant AVPlayer rejects, if the rejection is really about the DV/HDR variant rather than about masters generally. - Or serve the master only when the session has text tracks and the source is SDR, since the rejection reason does not apply there.
- Or, if neither is possible, expose the constraint (something like
nativeSubtitlesAvailableForCurrentRoute) so a host can tell the user their subtitles will not travel instead of silently dropping them.
Happy to test any of these on hardware. For reference, PiP subtitles work well through the same mechanism, so this is specifically the AirPlay variant.
Environment
- AetherEngine 5.23.5 (
17624b9c247195488aedb8bcbc93d2e6e8672e5f) - iPad Pro 11-inch (3rd gen), iPadOS 26; receiver is an Apple TV 4K (3rd gen)
- Source: 4K HEVC Main10 SDR MKV, E-AC-3 5.1, SubRip text subtitles, served by Jellyfin as a direct file
prepareNativeSubtitles = true,eagerNativeSubtitleReaders = true, selection viasetNativeSubtitleSelected(track:)
Activity
Merge pull request #228 from superuser404notfound/fix/ae227-airplay-n…
refactor(airplay): keep servedSourceIsHDR internal (#227)
superuser404notfound commentedon Jul 27, 2026
Confirmed, and the reading of the code is exactly right. This is by construction, not a timing problem, so the re-assert on
$isSessionReadywas never going to help.Two things met in the middle.
resolveUseMasterPlaylistalready forces the master for any routing-safe subtitled source (#15), so an SDR source with text tracks resolves tomaster.m3u8with theEXT-X-MEDIArenditions. The #86 AirPlay rewrite then discarded that: while external playback is active it rebuilt the URL on the LAN IP and forced/media.m3u8for every source. NoEXT-X-MEDIA, no legible group, sosetNativeSubtitleSelected(track:)had nothing to select against and reported success anyway.The constraint that motivated the blanket downgrade is narrower than the rule built on it. DrHurt's caveat on #86 was specifically that AVPlayer rejects a DV/HDR master on a receiver that is not in HDR or DV mode; the safe-universal media routing was a suggestion layered on top. An SDR variant is routing-safe on any receiver.
Shipped in 5.23.8 (fix
792af24, merged as0f90ca5):VIDEO-RANGE=SDRdoes not fool the external-display compatibility gate, which reads the realcolrand codec rather than the manifest string. So the second direction, master only when the source is SDR, is the one the manifests actually allow.nativeSubtitleRenditionsServedalready promised exactly that signal and was simply describing the locally resolved playlist instead of the one served to the receiver. It now reports the served one, so it goes false on an HDR/DV AirPlay hop and a host can say why rather than dropping subtitles silently.127.0.0.1media playlist, which a receiver cannot reach. It rewrites onto the LAN IP now.For the retest, the source described in the report (4K HEVC Main10 SDR) is exactly the fixed case. The log line to look for on the route change is:
Two notes that may simplify the host side:
[AetherEngine] #170 re-applying native subtitle ordinal=N after session-preserving reload), so selecting once is enough.setNativeSubtitleRendering(true)on entering the external route andsetNativeSubtitleRendering(false)on leaving keeps the two from overlapping; it resolves the ordinal internally and is the pattern documented in docs/formats.md.Leaving this open for the retest. Thanks for the report, in particular for tracing it to the two code paths and for recording the failure mode of both workarounds tried, which is what made it obvious this was construction rather than selection timing.
fix(airplay): hold the external-playback edge across the reload it st…
fix(airplay): judge the source by its VIDEO-RANGE, not by the device'…
diag(airplay): name every distinct HTTP client the loopback server se…
fix(airplay): keep the SDR master so native subtitles reach the recei…
feat(airplay): offer HDR sources the reduced HDR master, watchdogged (#…
diag(airplay): clamp the declared peak on the receiver's HDR master (#…
diag(airplay): drop RESOLUTION from the receiver's HDR master (#227)
diag(airplay): declare HDCP-LEVEL=TYPE-1 on the receiver's HDR master (…
diag(airplay): HDCP-LEVEL is not it either; document what the receive…
feat(airplay): offer the HDR master and remember a receiver that refu…
docs(airplay): the receiver's output mode decides, and in HDR it says…
fix(airplay): make the watchdog fire, then use the fallback to earn H…
fix(airplay): retry the master before falling back, not after (#227)
fix(airplay): one master attempt, then media (#227)
Merge pull request #229 from superuser404notfound/feat/ae227-airplay-…
superuser404notfound commentedon Jul 27, 2026
Follow-up, and an apology for 5.23.8: that release did not actually deliver on this issue. Three defects were stacked on the wireless-AirPlay hop, and a device session with an iPhone 17 Pro against two Apple TV 4K receivers took them apart. 5.23.9 is out with the result.
The hop was rebuilding itself in a loop and never rewrote onto the LAN address. The reload that the external-playback observer starts tears down the very AVPlayer item that observer watches, so AVPlayer reported a transient "external playback ended" mid-reload, which cleared the AirPlay flag before the load path read it. The rebuilt session served
127.0.0.1again, the receiver re-engaged, and that edge started the next reload: one full session rebuild per turn, indefinitely, with the LAN rewrite never once applied. This predates 5.23.8, so the earlier fix could not have worked through it. An edge landing during a session-preserving reload is now held and reconciled against the live audio route, which is what survives an item teardown.And 5.23.8 was a no-op on DV-capable hardware. The rule that keeps the master asked
videoRange != .sdr || effectiveDvMode, andeffectiveDvModeis a device capability rather than a property of the content, so on any DV-capable iPhone or iPad an SDR source took the HDR branch and lost its renditions anyway. The iPad Pro in the report is exactly that hardware. It reads the realVIDEO-RANGEnow.On the HDR question, the answer turned out to be the receiver's setting rather than a property of AirPlay:
SUPPLEMENTAL-CODECSMatch Dynamic Range does not count as HDR readiness: it switches only when tvOS decides the content warrants it, and it does not for AirPlay content. Against such a parked receiver nothing in the manifest helps, all measured: dropping the DV
SUPPLEMENTAL-CODECS, clamping the declaredBANDWIDTH, omittingRESOLUTION, declaringHDCP-LEVEL=TYPE-1. Declaring the range as SDR over HDR content was disproven earlier in #98. So for subtitles on HDR content over AirPlay, the receiver's video format has to be fixed to HDR or Dolby Vision, and the engine surfaces which playlist is actually in use throughnativeSubtitleRenditionsServed.The refusal itself is worth recording, because it is invisible: no
-11868, no failed item, the rate flickers toplayingfor one tick so evenhasEverPlayedlatches, and the picture simply never starts. A progress watchdog now catches it, five seconds without a segment fetched reloads the LAN media playlist, and that receiver is remembered for the rest of the process so it is never made to wait twice.Two notes for the host side, both from the same session:
setNativeSubtitleRendering(true)on entering the route, andfalseon leaving, is for.Leaving this open for a retest on 5.23.9. Thanks for the report, and for the precision in it: pinning this to the two code paths rather than to selection timing is what made the construction problem visible.
feat(airplay): offer the HDR master to the receiver, gated on readine…
feat(visionos): support visionOS as a build platform (superuser404not…
fix(subtitles): keep load-declared external subtitles on the remote-H…
feat(subtitles): declare sidecar subtitles as renditions on the remot…
fix(hlsserver): the local origin answers only its own session
Merge pull request #562 from superuser404notfound/fix/hold-airplay-ed…
fix(airplay): every session-preserving rebuild holds the external-pla…
fix(network): keep the local server's session token out of the log (a…
fix(airplay): the refused-master fallback rejoins a live playlist ins…
fix(startup): a local start is a plain play; the readiness gate is Ai…
fix(startup): a local start is a plain play; the readiness gate is Ai…