Skip to content

Live HLS carriage is learned only after a full native mount plus the 4 s watchdog grace; probe it alongside the mount #293

Closed

Description

@superuser404notfound

What happens today

On a live nativeRemoteHLS load the engine hands the master to AVPlayer and only afterwards learns whether the carriage is one AVFoundation can build a video track for. RemoteHLSIngestFallback.Watchdog arms at readyToPlay, polls item.tracks at a 0.5 s cadence and fires the #168 reroute after 8 ticks. Per first open of a HEVC-in-MPEG-TS channel that discovery costs:

  • a full native mount and readyToPlay on a session that can never show a picture,
  • 4 s of audio-only black on top of it,
  • and only then the reroute plus the ingest join.

In the #199 retest the first real video frame lands at t+9.0 s, roughly 4 s of which is the grace.

#199's RerouteVerdictMemory removes that cost on the second load of the same URL inside one process. The first load still pays in full, in every process, and a host that relaunches per tune pays it on every tune.

Why this belongs in the engine

The reporter in #199 has meanwhile shipped a host-side master probe that routes a known HEVC-in-TS channel onto the ingest before the engine mounts natively (their Run A). That is a host working around engine behaviour, and the engine already owns a stronger version of the same evidence: #268 classifies exactly this case from the playlist plus the first segment's PMT (MPEGTransportStreamCodecProbe, HEVC stream_type 0x24), with no AVPlayer involved. It is simply gated to finite VOD. Live still learns the hard way.

There is a second hole in the same place: the watchdog needs master variant evidence, so a live media playlist URL (no master, no AVAssetVariants) is never judged at all. advertisesVideo is nil there, which disarms after the grace by design. HEVC-in-TS behind a direct media playlist therefore stays audio-only black on the native path indefinitely.

Proposed change

Run the carriage probe concurrently with the native mount, never in front of it, so nothing is serialized ahead of first frame.

  1. Gate, so a healthy stream pays no extra origin connect. Probe only when the master advertises a codec the HLS Authoring Spec sanctions in fMP4 only (HEVC, Dolby Vision, AV1), or when there is no master evidence at all (direct media playlist, the case the watchdog can never judge). An H.264 master never probes. IPTV origins with per-token connection limits are the reason this gate exists rather than probing unconditionally.
  2. Evidence chain reused from HEVC-in-MPEG-TS HLS VOD direct media playlist routes to AVPlayer with 0x0 video #268. Fetch the playlist, resolve the highest-bandwidth variant when it is a master, range-read the head of the first segment and classify the PMT. EXT-X-MAP ends it early as fMP4 without fetching a segment at all. Positive evidence only: inconclusive, encrypted and non-HEVC verdicts keep the native route.
  3. One fire path. The probe result feeds the same pure Watchdog, which fires as soon as a positive verdict lands instead of waiting the grace out. A video track appearing at any point still wins and disarms, so even a wrong verdict cannot pull a working session off the native path.
  4. The fired verdict is recorded in the Rerouted live-ingest session death relands on the known-bad native path: #168 verdict not remembered, no in-engine revive #199 RerouteVerdictMemory exactly as today, so later loads in the same process skip the probe as well.
  5. The reroute log line reports the grace it removed, so a reporter measuring time to first frame can see this item separately rather than the sum (the AE#274 lesson).

Expected effect: the first open of a HEVC-in-TS live channel reroutes within about two small playlist fetches instead of a mount plus 4 s of black, in every process, and no host needs a probe of its own. Direct media playlists become judgeable for the first time.

Not in scope

What remains of the #199 time to first frame is the live-ingest join itself: Run A there shows a 5.2 s self-healed stall at the join with no reroute involved at all. That is a separate thread.

Activity

  1. superuser404notfound commented on Aug 3, 2026

    @superuser404notfound
    OwnerAuthor

    Implemented on main in 86abea95 (PR #294, merged a76e1f88), along the lines above.

    HLSCarriageProbe carries the #268 evidence chain (playlist plus the first segment's PMT) without the VOD-only requirements, so a rolling live window is judgeable too, and it runs concurrently with the native mount. The verdict never fires on its own: it feeds the same pure RemoteHLSIngestFallback.Watchdog, which ends its wait early on positive evidence, so a video track that does build still wins and no working session leaves the native path. The probe is gated on AVAssetVariant evidence AVFoundation has already fetched, so only an fMP4-only codec (HEVC, Dolby Vision, AV1) or a source with no master evidence at all reaches the network; an H.264 channel spends nothing. A live media playlist URL is judged for the first time, the case the watchdog structurally could not reach.

    One deliberate limit: the reroute still fires on the watchdog's first tick after readyToPlay rather than before it, which keeps a single firing path and one interleaving with the mount's own state machine. The saving is the grace, roughly 3.5 s of the 4 s, not the mount itself.

    Verification: new Issue293LiveCarriageProbeTests (21 tests, all watched failing first), full suite green (449 XCTest plus 1479 swift-testing), tvOS and iOS Simulator builds clean, CI green on PR #294.

    Unreleased so far, and the device leg is open here for want of a live HEVC-in-MPEG-TS channel. The markers to look for are [NativeAVPlayerHost] #N carriage probe: hevcInMPEGTS (#293) and the reroute line that follows it, which states the grace it removed.

  2. superuser404notfound commented on Aug 3, 2026

    @superuser404notfound
    OwnerAuthor

    Measured on the Mac. aetherctl play --native-hls now reaches the bypass, and the hlsfixture master carries CODECS / RESOLUTION so AVFoundation reports variant video attributes at all (without them the fixture would have run green while exercising nothing). Origin: real keyframe-aligned MPEG-TS segments from ffmpeg -f hls, served as a sliding live window by a request-logging origin. Fixtures verified at the PMT, not from the encoder flag: 0x24 + 0x0f for the HEVC one, 0x1b + 0x0f for the H.264 one.

    origin probe verdict what it cost outcome
    master CODECS="hvc1...", HEVC in TS hevcInMPEGTS 1 master + 1 media playlist + 1 ranged segment head fires 4.0 s before the grace would have concluded it, reroutes, ingest plays
    media playlist, no master, HEVC in TS hevcInMPEGTS 1 media playlist + 1 ranged segment head same, and this is the case the watchdog structurally could not judge
    master CODECS="avc1...", H.264 in TS probe never runs 0 requests watchdog disarms on the built video track, native playback continues
    master + EXT-X-MAP otherCarriage 0 segment fetches no reroute
    master + EXT-X-KEY:METHOD=AES-128 inconclusive 0 segment fetches no reroute

    Exactly one ranged request appears in the whole positive run, so the probe reads one segment head and stops.

    Two caveats on what this proves. macOS AVFoundation behaved like tvOS here (readyToPlay with audio and no video track for HEVC in TS), which is what makes the early fire observable at all, but it is not a substitute for the device: this run says nothing about tvOS AVKit integration. And the first attempt against a cold origin failed with -12884 on the loopback item, which turned out to be the synthetic window being one segment deep at join time; against a warmed window the same run plays through. Worth stating because it is the harness, not the engine.

    Still open for a real channel, where the interesting number is the time to first video frame with and without this. The lines to grep are carriage probe: and the reroute line that names the grace it removed.

  3. superuser404notfound commented on Aug 3, 2026

    @superuser404notfound
    OwnerAuthor

    @kskchaitanya1993 this is out in 6.6.0, together with #288, #289 and #290, so the patches carried downstream against every release can go.

    This issue exists because of the #199 retest: a host having to probe the master itself to route a known HEVC-in-TS channel is work the engine should be doing, and thanks for putting that configuration on the record clearly enough to see it. The engine now reads the carriage from the source (the playlist plus the head of one segment, the same PMT evidence #268 uses for VOD) concurrently with the native mount, so the reroute no longer waits out the 4 s watchdog grace, on the first open and in every process. The #199 verdict memory became the second-order path rather than the only one, and a live media playlist URL with no master is judged for the first time.

    If the debug lever that restores native-first is still around, the measurement worth having is the time from tune to the first real video frame on 6.6.0, against the t+9.0 s Run B recorded. Two lines carry it:

    • [NativeAVPlayerHost] #N carriage probe: hevcInMPEGTS (#293)
    • the reroute line right after it, which states the grace it removed: ... rerouting 4.0s before the watchdog grace would have concluded the same (#293)

    A full 4.0 s there means the verdict was in before the watchdog even armed. Less than that means the probe landed later than the mount on a real origin, which is exactly the number a loopback run cannot produce and the one I would most like to see.

    For the shipping configuration: with this in the engine, routing HEVC-in-TS channels host-side is redundant now, though keeping it costs nothing. The engine's version fetches at most two small playlists plus one bounded segment head, and only when the master advertises a codec the HLS Authoring Spec sanctions in fMP4 alone, or when there is no master to judge at all. An H.264 channel spends nothing, which matters for origins that cap concurrent connections per token.

    The limit of what I can claim from here: the measurements above are macOS against a synthetic origin. AVFoundation there behaved like tvOS (readyToPlay with audio and no video track ever), which is what made the early fire observable at all, but nothing about AVKit on the device follows from it.

  4. kskchaitanya1993 commented on Aug 3, 2026

    @kskchaitanya1993

    Ran the device leg. Built main (6.6.0 prep, 2188b17) into our tvOS app and drove it on an Apple TV 4K 3rd gen against a live HEVC-in-MPEG-TS channel — real keyframe-aligned TS segments served as a sliding window, HDR10 4K-class HEVC, hvc1 in CODECS, no EXT-X-MAP. Our own host-side probe is disabled for all of these (--uitest-no-ts-probe), so the engine's path is what's being measured.

    All three of your cases reproduce on device, and the media-playlist one is the big one.

    1. Master with CODECS="hvc1…", HEVC in TS

    18:22:39  ladder: rung 1 → Aether (live)
    18:22:39  [NativeAVPlayerHost] #1 load url=<ORIGIN>/live/hevc-hdr/master.m3u8 headers=1
    18:22:39  [NativeAVPlayerHost] #1 carriage probe: hevcInMPEGTS (#293)
    18:22:39  [NativeAVPlayerHost] #1 the source's own PMT declares HEVC in MPEG-TS, so AVPlayer will build no video track; rerouting 4.0s …
    18:22:39  [AetherEngine] #168: rerouting onto the live-ingest loopback path
    18:22:39  [NativeAVPlayerHost] #2 load url=http://127.0.0.1:61384/media.m3u8
    18:22:45  AETHER first REAL video frame rendered (t+6.0s)
    

    Probe verdict, reroute and loopback mount all land in the same second as the mount. First real video t+6.0s against t+9.0s on 6.5.5 on the identical channel and rig — the ~3s saving lines up with the grace you say it removes, allowing for the second-granularity of our log.

    2. Media playlist, no master — this is the one worth having

    6.6.0:

    18:23:48  [NativeAVPlayerHost] #1 load url=<ORIGIN>/live/hevc-hdr/index.m3u8
    18:23:48  [NativeAVPlayerHost] #1 carriage probe: hevcInMPEGTS (#293)
    18:23:48  [AetherEngine] #168: rerouting onto the live-ingest loopback path
    18:23:53  AETHER first REAL video frame rendered (t+5.0s)
    

    6.5.5, same URL, 60s window:

    18:25:45  [NativeAVPlayerHost] #1 load url=<ORIGIN>/live/hevc-hdr/index.m3u8
    18:26:05  AETHER no first frame in 20s on native HLS → host-side TS ingest reroute (engine #168 missed it)
    18:26:05  [NativeAVPlayerHost] #2 load url=http://127.0.0.1:61534/media.m3u8
    18:26:09  AETHER first REAL video frame rendered
    

    The engine emitted no #168 at all on 6.5.5, exactly as you predicted — advertisesVideo is nil so the watchdog disarms. What rescued it was a host-side net of ours that reroutes after 20s of no first frame, which exists precisely because we'd been bitten by cases the engine couldn't judge. Picture at ~24s on 6.5.5 versus 5s on 6.6.0. And for any host without such a net, your "audio-only black indefinitely" is the correct description — ours only looks survivable because we'd papered over it.

    3. H.264 master — control

    18:24:33  ladder: rung 1 → Aether (live)
    18:24:33  [NativeAVPlayerHost] #1 load url=<ORIGIN>/live/h264/master.m3u8
    18:24:35  AETHER first REAL video frame rendered (t+2.0s)
    

    No carriage probe line, native playback, t+2.0s. The gate holds — a healthy H.264 channel pays nothing.


    One concern, on the segment head fetch

    This is the thing I'd want to raise before it meets IPTV origins at scale.

    Our host probe stops at playlists on purpose: master plus first media playlist, classified from CODECS + .ts segment naming + absence of EXT-X-MAP. It never fetches a segment. That is weaker evidence than your PMT read — you are right that the PMT is authoritative and that suffix-sniffing is not — but it was a deliberate trade, because a great many IPTV accounts are capped at one or two concurrent connections per token, and a media fetch is what those caps count. Playlist fetches generally are not.

    Your gate settles which streams probe, and it settles it correctly. But the streams it admits — HEVC/DV/AV1, or no master evidence — are exactly the IPTV live channels where the cap bites, and there the ranged segment head is a second media connection to the origin opened while AVPlayer is mounting the same stream. On a one-connection token the plausible failure is the provider dropping or refusing one of the two, which would land as an intermittent failure to start on precisely the channels this feature exists to speed up. It would also be hard to attribute: it would look like a flaky origin, not like the probe.

    I have not reproduced that — our test bed has no connection cap, so this is a design concern rather than a bug report. Two thoughts, take or leave:

    • The playlist-only signals (CODECS advertising HEVC, .ts segments, no EXT-X-MAP) are usually sufficient to reach the same verdict without touching a segment. Weaker, but free. Falling back to them when the segment read fails, rather than going inconclusive, would keep the win on capped origins.
    • If the segment read stays unconditional, a host-facing opt-out would let an app that knows its provider is capped choose the weaker evidence. We would use it.

    Happy to run anything else on the device leg — the rig is set up and the channel is deterministic, so re-running a variant is cheap.


    This comment was drafted and posted automatically by Claude, working on behalf of @kskchaitanya1993.

  5. kskchaitanya1993 commented on Aug 3, 2026

    @kskchaitanya1993

    Correction to my last comment: I described the build as main / 6.6.0 prep, implying unreleased. It wasn't — 6.6.0 was tagged at 18:09Z, before the runs at 18:22Z, and the commit I built is the tag:

    main tested : 2188b17fd550
    6.6.0 tag   : 2188b17fd550
    

    So those numbers are 6.6.0 as released, not a pre-release snapshot. Same figures, better provenance.

    We're now on 6.6.0 proper, with our local patch set at zero for the first time since we started carrying one — nativePlayerLayer and softwareHostFramesEnqueued are public, the Match Content guard is in waitForSwitch, and the SAR bound is yours and better than ours. Thanks for taking all four rather than leaving them downstream.

    The connection-cap point in my previous comment stands on its own and isn't affected by this correction.


    This comment was drafted and posted automatically by Claude, working on behalf of @kskchaitanya1993.

  6. superuser404notfound commented on Aug 4, 2026

    @superuser404notfound
    OwnerAuthor

    That is the leg I could not produce from here, and both halves of it are the ones worth having: t+6.0s against t+9.0s on the master, and t+5.0s against roughly 24s on the direct media playlist, where 6.5.5 emitted no #168 at all. Thank you for running it, and for the provenance correction. 2188b17f being the tag rather than a pre-release snapshot is what makes those numbers quotable, and knowing that a host-side 20s net was the only thing standing under the media-playlist case is the part I would not have inferred from the logs.

    So the device leg is done and I am closing this. The connection-cap point is not being dropped with it: it moves to #296, where it is already fixed on a branch (#297).

    The cap concern

    It is right, and it deserves more than the fallback suggested for it. Working through it, neither defect turns out to be "the probe reads a segment".

    It reads one where the playlists already answer. An fMP4 media segment requires an EXT-X-MAP (RFC 8216 4.3.2.5). A master advertising hvc1/hev1/dvh1/dvhe/av01 over a window that carries no EXT-X-MAP is therefore that codec in MPEG-TS, and both halves of that are free: the CODECS attribute is one AVFoundation has already parsed and hands over, and the media playlist is a playlist fetch. This is your playlist-only signal, with the suffix sniff replaced by the normative one. Your channel 1 stops touching a segment entirely.

    It reads it at the one moment where losing the race is expensive. The verdict cannot be acted on before readyToPlay in any case, since it feeds the watchdog and the watchdog arms there. Running the read against the mount therefore buys nothing but a head start on the probe's own latency, and that is exactly what puts it in contention. The asymmetry is the whole point: a connection lost at load time can cost the mount, one lost after readyToPlay can only cost the verdict, on a session that is already showing black. So the read stays where it is the only evidence there is, and waits.

    That second part is why I did not take the "fall back to the weaker signal when the segment read fails" route as such. What survives the playlist stage is the direct media playlist and the master with no CODECS, and there the PMT is the only thing separating HEVC in MPEG-TS from H.264 in MPEG-TS. Inferring it from the playlist would either pull working H.264 channels onto the ingest or send your channel 2 back to indefinite black, which is the case that was worth the most on your rig.

    Per channel shape, in media connections:

    shape 6.6.0 with #297
    master advertising HEVC/DV/AV1, no EXT-X-MAP 1, against the mount 0
    master advertising HEVC/DV/AV1, AES-128 0, inconclusive, full grace 0, settled early
    direct media playlist, no CODECS 1, against the mount 1, after readyToPlay
    H.264 master 0 0

    The AES-128 row is a side effect worth naming, since encrypted IPTV channels are not rare: the PMT is not what is being read on the playlist branch, the ingest decrypts that carriage, and the alternative for those channels today is the full grace ending in the same reroute.

    On the opt-out

    I would rather not add one, and after the above I think it would mostly be a way to opt back into the failure it was meant to avoid. The only source that still reaches a media byte is one where the alternative is indefinite audio-only black, and that byte is no longer spent against the mount. A session whose watchdog disarms first, or which never reaches readyToPlay, now spends nothing at all. LoadOptions.nativeRemoteHLSIngestFallback remains the coarse switch for a host that wants none of the recovery path.

    If your provider still bites after this, that is a concrete report rather than a design concern, and the knob is a small thing to add at that point.

    What is worth measuring on the branch

    The log lines moved a little. The verdict line now names where the evidence came from, so the two paths are separable in a capture:

    • [NativeAVPlayerHost] #N carriage probe: hevcInMPEGTS from playlist evidence (#293)
    • [NativeAVPlayerHost] #N carriage probe: hevcInMPEGTS from segment PMT evidence (#293)
    • and, before the deferred read, carriage probe: the playlists cannot settle this one, so the segment head waits for readyToPlay rather than compete with the mount (#296)

    carriage probe: still greps for all of them.

    Two numbers would settle it, if the rig is still up: your channel 1 should reach the same fire with no request to a segment at all in the origin log, and your channel 2 should still fire early, though its verdict now lands after readyToPlay rather than during the mount, so I would expect it a fraction later than the 5.0s you measured. If that fraction turns out to be a whole tick, the deferral is costing more than it should on a real origin and I would want to know.

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

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions