Skip to content

Native subtitles cannot reach a wireless AirPlay receiver: renditions live in the master playlist, but the AirPlay path forces the media playlist #227

Open

Description

@brandomoore

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 master EXT-X-MEDIA:TYPE=SUBTITLES tags".
  • 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-MEDIA available 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 via setNativeSubtitleSelected(track:)

Activity

  1. added 2 commits that reference this issue on Jul 27, 2026
  2. superuser404notfound commented on Jul 27, 2026

    @superuser404notfound
    Owner

    Confirmed, and the reading of the code is exactly right. This is by construction, not a timing problem, so the re-assert on $isSessionReady was never going to help.

    Two things met in the middle. resolveUseMasterPlaylist already forces the master for any routing-safe subtitled source (#15), so an SDR source with text tracks resolves to master.m3u8 with the EXT-X-MEDIA renditions. The #86 AirPlay rewrite then discarded that: while external playback is active it rebuilt the URL on the LAN IP and forced /media.m3u8 for every source. No EXT-X-MEDIA, no legible group, so setNativeSubtitleSelected(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 as 0f90ca5):

    • An SDR source keeps its master on the AirPlay hop, so the renditions travel. The master's rendition URIs are relative, so they resolve against the LAN base with no further work.
    • HDR and DV keep the media downgrade. The first suggested direction, a master with a single SDR variant, was tried and reverted in Unify handling of dynamic range checks #98 Stage 1.5: forcing VIDEO-RANGE=SDR does not fool the external-display compatibility gate, which reads the real colr and codec rather than the manifest string. So the second direction, master only when the source is SDR, is the one the manifests actually allow.
    • The third direction needed no new API in the end. nativeSubtitleRenditionsServed already 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.
    • One latent bug came along: the master-rejection fallback reloaded the 127.0.0.1 media 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:

    [AirPlay] loadNative serving via http://<lan-ip>:<port>/master.m3u8 (keepMaster=true sourceIsHDR=false subtitle renditions carried)
    

    Two notes that may simplify the host side:

    • The re-assert loop can go. The AirPlay route change runs a session-preserving reload that captures and replays the rendition pick by itself ([AetherEngine] #170 re-applying native subtitle ordinal=N after session-preserving reload), so selecting once is enough.
    • The double-draw seen after returning to the device is the same replay meeting the host overlay: the rendition is restored on the return reload while the overlay also paints. Driving setNativeSubtitleRendering(true) on entering the external route and setNativeSubtitleRendering(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.

  3. superuser404notfound commented on Jul 27, 2026

    @superuser404notfound
    Owner

    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.1 again, 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, and effectiveDvMode is 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 real VIDEO-RANGE now.

    On the HDR question, the answer turned out to be the receiver's setting rather than a property of AirPlay:

    Receiver output format Master handed over Result
    fixed 4K Dolby Vision 4K PQ + DV SUPPLEMENTAL-CODECS plays, subtitles travel
    4K SDR, Match Dynamic Range on 4K PQ, every variation tried refused
    4K SDR, Match Dynamic Range on SDR 1080p H.264, 720p HEVC plays, subtitles travel

    Match 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 declared BANDWIDTH, omitting RESOLUTION, declaring HDCP-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 through nativeSubtitleRenditionsServed.

    The refusal itself is worth recording, because it is invisible: no -11868, no failed item, the rate flickers to playing for one tick so even hasEverPlayed latches, 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:

    • The re-assert loop can go. The AirPlay route change runs a session-preserving reload that replays the rendition pick by itself.
    • The double-drawn subtitles seen on returning to the device are the host overlay meeting the restored rendition. Whichever surface renders the rendition, the on-frame overlay should be hidden while it does; that is what setNativeSubtitleRendering(true) on entering the route, and false on 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.

  4. added a commit that references this issue on Sep 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions