Skip to content

nativeRemoteHLS: external subtitles can never become renditions (load-time dropped, post-load overlay-only) #316

Open

Description

@edde746

On the nativeRemoteHLS bypass, LoadOptions.externalSubtitles is dropped: load() returns through the bypass branch before the registration step, so a host that declares sidecars at load time gets nothing. The only way to get them into subtitleTracks there is addExternalSubtitleTrack after load, which AetherEngine+Subtitles.swift:919-928 documents as overlay-only — no native WebVTT rendition / PiP.

That combination leaves remote-HLS sessions with no route to a rendition-backed external subtitle. It matters for Plex and Jellyfin transcodes, which are served as .m3u8 and are told subtitles=none, so the stream itself carries no text: the sidecar is the only copy. Whenever the picture leaves the host's view hierarchy — PiP, AirPlay, a wired external display — the host overlay is suppressed and the subtitle simply disappears, while the same source on the probe-and-loopback path renders it.

Could loadRemoteHLS honour LoadOptions.externalSubtitles and declare them as legible renditions (AVMutableMediaSelectionGroup / the same declaration the loopback path makes)? Failing that, a documented way to ask for rendition eligibility on the bypass would let hosts choose between passthrough and external-route subtitles knowingly, rather than discovering it as a disappearing caption.

For context: choosing the loopback path instead is not a workaround here — the bypass is what preserves E-AC-3/Atmos passthrough for these sources.

Activity

  1. added a commit that references this issue on Aug 7, 2026
  2. superuser404notfound commented on Aug 7, 2026

    @superuser404notfound
    Owner

    Both halves of this are confirmed, and the first one is worse than reported: the declaration was not just unused, it was dropped without a trace. load() routes a nativeRemoteHLS session into loadRemoteHLS and returns from there, well before the point where the probe path registers LoadOptions.externalSubtitles, so subtitleTracks came back empty with no error and no log line. Nothing distinguished a dropped option from a source that has no subtitles. The AE#154 reroute onto the same bypass dropped them too, and the legible-group discovery would have undone the registration anyway: it assigned subtitleTracks wholesale instead of merging, so on a source carrying its own renditions the sidecars would have been delisted a beat after appearing.

    One correction to the suggested route, since it shaped the fix. AVMutableMediaSelectionGroup is not reachable here: media selection on an HLS asset comes from the playlist and from nowhere else, and there is no API that attaches an option to a remote AVURLAsset. So the documentation on addExternalSubtitleTrack is not a policy that could be relaxed, it is a description of the only thing that path can do. The only route to a rendition is a master the engine writes itself.

    Shipped in 6.14.0 (56c17a0), and that is what it does now. For a VOD source the engine fetches the origin master, makes every variant, audio, I-frame and key URI absolute against it, adds one EXT-X-MEDIA:TYPE=SUBTITLES per text sidecar and serves that master from the loopback origin:

    #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="DE",LANGUAGE="de",DEFAULT=NO,AUTOSELECT=NO,URI="subs_0.m3u8"
    #EXT-X-STREAM-INF:RESOLUTION=1920x1080,CODECS="hvc1.2.4.H153.B0,mp4a.40.2",...,SUBTITLES="subs"
    https://devstreaming-cdn.apple.com/.../cmaf/hvc/1080p_5800/hvc_1080p_5800.m3u8
    

    The point you made about passthrough is the constraint the whole design is built around: the media never moves. AVPlayer fetches every A/V byte straight from the origin, so E-AC-3 and Atmos are untouched, and only the master and the WebVTT renditions come from the loopback. The tracks keep the external ids they were registered under, and selecting one drives AVMediaSelection instead of the sidecar decode, so the overlay and the rendition can never draw at once.

    No new option to opt into. Declaring sidecars at load is the opt-in, and everything that does not line up keeps the origin URL with overlay-only subtitles and logs the reason: a live playlist (no EXT-X-ENDLIST, where a whole-program WebVTT makes no sense), a bitmap .sup sidecar, a playlist that will not rewrite, an origin slower than the 5 s budget. A load is never failed over this.

    One measurement worth passing on, because it cost the first implementation. AVMediaSelectionOption.displayName is not the rendition's NAME: AVFoundation derives a localized language name from LANGUAGE and discards NAME. Against Apple's own CMAF master, an injected NAME="DE" reads back as German and the origin's NAME="简体中文" as Chinese. The verbatim attribute survives in commonMetadata under the m3u8/NAME identifier, which is what the selection lookup and the deduplication key on. Anything host-side that identifies a rendition by display name has the same trap waiting.

    What I could verify headless, against that master with an .srt sidecar: 8 legible renditions surfaced (7 from the origin, 1 injected, no duplicate entry for the sidecar), HEVC 1080p playing from the CDN throughout, and selecting the external id fetching subs_0.m3u8 and subs_0_0.vtt from the loopback. What I could not: that the cues are actually painted, and the PiP / AirPlay / external-display end of it. No host here reaches this path, so that part is genuinely open, and a retest on your side is what would close it.

    If it helps to reproduce independently, aetherctl play --sidecar <lang>=<path> --subs <lang> <master.m3u8> drives the whole chain and logs the served master body plus the settled track list.

    One known edge, documented in the code but not measured: cue times are used verbatim on the item axis. If an origin rebases its VOD timeline (a transcode started at an offset whose playlist still begins at zero) while the sidecar stays relative to the whole file, the cues will be shifted by that offset. Jellyfin and Plex both looked absolute from here, but if you see a constant offset on a resumed transcode, that is the first thing to check and worth a separate issue.

  3. added a commit that references this issue on Aug 8, 2026
  4. edde746 commented on Aug 8, 2026

    @edde746
    Author

    Retested from the host on 6.15.2, with the load-time declaration as the only registration
    (our post-load compensation is deleted — both entrances covering it upstream is what made
    that a clean delete rather than a conditional one).

    Confirmed here: declared text sidecars surface as legible renditions under the external ids
    they were registered with, alongside the origin's own renditions, no duplicates; selecting
    one drives AVMediaSelection, and our overlay never draws while a rendition is selected.
    The displayName trap you flagged doesn't bite this host — selection and dedup key on the
    external ids and ordinals, and nothing reads AVMediaSelectionOption.displayName. Worth the
    warning all the same; it would have been the natural thing to key on.

    Still owed: the half you explicitly couldn't reach headless. PiP, AirPlay and wired-display
    cue painting need a device pass with a real Plex/Jellyfin transcode told subtitles=none;
    that's scheduled, and I'll report the matrix (plus the cue-rebase edge on a resumed
    transcode, which we'll watch for) as a follow-up comment. If you'd rather close on the
    rendition mechanics and take the presentation matrix as a new issue if it shows anything,
    also fine.

  5. added a commit that references this issue on Aug 9, 2026
  6. superuser404notfound commented on Aug 9, 2026

    @superuser404notfound
    Owner

    Retest noted, and thanks for deleting the post-load compensation outright rather than conditioning it. Both entrances registering upstream is exactly what that delete was meant to buy, so it is good to see it spend that way.

    On the choice you offered: I would rather leave this open, and the reason turned into something concrete. Reading back over the presentation matrix before it runs, there is a defect sitting in the AirPlay row, and it would have reported as a failure that has nothing to do with cue painting.

    What the matrix would have hit

    A wireless AirPlay receiver fetches for itself, so the engine reloads the session on a route change to re-resolve the playback URL onto the device's LAN IP (#86, #227). That reload skipped the nativeRemoteHLS bypass wholesale, on the premise written into the guard: remote HLS is already receiver-reachable.

    That held for exactly as long as the bypass could only ever play the origin URL, and #316 is what stopped it holding. With sidecars declared at load, the bypass plays the master the engine serves from its own loopback origin, and 127.0.0.1 means nothing on a receiver.

    So engaging AirPlay mid-playback handed the receiver an address it cannot fetch. That is not a subtitle failure, it is the whole session. Nothing downstream catches it either: the progress watchdog that recovers a refused manifest requires a nativeVideoSession, which this bypass never builds, so there was no watchdog and no media-playlist fallback. On device it shows up as the silent park, no -11868, no failed item, the rate flickering to playing for a single tick.

    Why it matters for the run specifically

    The two orderings behave differently, which is the part worth having in advance:

    Case Before the fix
    AirPlay engaged before playback starts works, the LAN swap is applied when the proxy mounts
    AirPlay engaged mid-playback receiver parks silently
    Wired display (HDMI adapter) unaffected, the device stays the stream origin
    PiP unaffected, no route change
    tvOS unaffected, external playback never engages there

    Only the second row is the bug, and it is the row a hand-driven pass naturally produces, since starting playback and then reaching for the route picker is the obvious sequence. A matrix run against a build without the fix would have recorded "AirPlay: no video at all" and sent the investigation at the rewritten master.

    The fix

    On main in f626ec6b. The discriminator is not the backend, it is where the session's playback URL points, so that is what the guard reads now:

    static func routeChangeNeedsReload(isRemoteHLSBypass: Bool,
                                       bypassServesLoopbackOrigin: Bool) -> Bool

    Both edges reload, matching the loopback path: engaging swaps in the LAN IP, ending puts the session back on the loopback instead of leaving it depending on a LAN address that outlives the receiver. The reload itself already worked on this path and was only never started. load() seats the carryover registry before the bypass branch, so the proxy is rebuilt with the same external ids, and loadedURL holds the origin rather than the proxy URL, so the reload re-enters at the origin instead of treating the loopback master as its source.

    The line to look for, which also tells the two shapes of the bypass apart:

    [AirPlay] external playback active (wireless) -> LAN reload (remote-HLS bypass on its #316 subtitle origin)
    

    It goes into the next release. Same boundary as #316 itself for the rest: what a receiver does with the swapped URL is not observable headless, so the device pass is still what closes this, now with one fewer known defect in its way. Keeping the issue open for it, and the cue-rebase edge is worth watching for in the same run.

  7. superuser404notfound commented on Aug 9, 2026

    @superuser404notfound
    Owner

    Released as 6.16.1, so the presentation matrix has a build to run against.

    Nothing else in it, and no API change. Note it moves the version pin only: a bypass playing the origin directly behaves exactly as before, so if the sequence in the run is to engage AirPlay before starting playback, the pass is measuring the same thing on either build.

  8. added a commit that references this issue on Sep 25, 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