Skip to content

Carriage probe spends a media connection where the playlists already answer, and spends it against the mount #296

Closed

Description

@superuser404notfound

What happens today

The #293 carriage probe reads the head of the first segment to classify the PMT, and it starts that read in NativeAVPlayerHost.load, concurrently with the native mount of the same stream. On a healthy origin that costs one bounded ranged request and buys about 3.5 s of the watchdog grace back.

On an origin that caps concurrent connections per token, which is the norm for IPTV subscriptions (commonly one or two), it is a second media connection opened while AVPlayer is establishing its own. Playlist fetches are generally not counted against such caps; segment fetches are. The streams the #293 gate admits, an fMP4-only advertised codec or no master evidence at all, are exactly the live channels where the cap bites.

The plausible failure is the origin refusing or dropping one of the two connections, which lands as an intermittent failure to start on precisely the channels the probe exists to speed up, and it would read as a flaky origin rather than as the probe. Reported as a design concern by @kskchaitanya1993 in #293 after the device leg, not reproduced (their test bed has no cap).

Why the answer is not "probe less"

The suggestion on #293 was to fall back to playlist-only signals when the segment read fails, or to give the host an opt-out. Both leave the actual defect in place. There are two of them, and neither is "the probe reads a segment".

1. The read happens where the playlists already answer. An fMP4 media segment requires an EXT-X-MAP (RFC 8216 4.3.2.5). A master that advertises hvc1/hev1/dvh1/dvhe/av01 in CODECS, whose media playlist carries no EXT-X-MAP, is therefore an fMP4-only codec in MPEG-TS carriage: the #168 case, settled by two playlist fetches and no media byte at all. AVFoundation has already parsed that CODECS attribute (AVAssetVariant), and the media playlist is a playlist fetch. Today that case still reads a segment head to confirm what the playlists have already said.

2. The read happens at the one moment where losing the race is expensive. The verdict cannot be acted on before readyToPlay regardless: it feeds the watchdog, which arms there, and that single firing path is deliberate (#293). Running the segment read concurrently with the mount therefore buys nothing but a head start on the probe's own latency, and it is what puts the probe in contention with the mount. The asymmetry matters: a connection lost at t=0 can cost the mount, while one lost at readyToPlay can only cost the verdict, on a session that is already showing black.

Proposed change

Split the probe into a playlist stage and a segment stage.

  1. Playlist stage, concurrent with the mount as today, playlists only. When the master advertises a codec the HLS Authoring Spec sanctions in fMP4 alone and the media playlist has no EXT-X-MAP, settle hevcInMPEGTS there, without fetching a segment. EXT-X-MAP still settles otherCarriage as it does now. AES-128 with a key URI no longer blocks this branch, because the PMT is not what is being read: the ingest decrypts that carriage, and the alternative for those channels today is the full grace followed by the same reroute.
  2. Segment stage, deferred to readyToPlay. Only a source the playlists cannot settle reaches a media byte, which is the direct media playlist and the master with no CODECS: there the PMT is the only evidence that separates HEVC in MPEG-TS from H.264 in MPEG-TS, and dropping it would either pull working H.264 channels off the native path or return that case to indefinite black. Deferred to readyToPlay, it no longer contends with the mount, and it is never spent at all on an origin that never gets there. The verdict still lands inside the first tick or two of the grace, so the saving stays about 3.5 s of the 4 s.

Effect on the connection budget, per channel shape:

shape media connections before after
master advertising HEVC/DV/AV1, no EXT-X-MAP 1, concurrent with the mount 0
master advertising HEVC/DV/AV1, AES-128 0, verdict inconclusive, full grace 0, verdict early
direct media playlist, no CODECS 1, concurrent with the mount 1, after readyToPlay
H.264 master 0 0

Not in scope

A host-facing opt-out for the segment read. After this change the only source that reaches a media byte is one where the alternative is indefinite audio-only black, and the read no longer competes with the mount, so the switch would mostly be a way to opt back into the bug it was meant to avoid. LoadOptions.nativeRemoteHLSIngestFallback already turns the whole recovery path off for a host that wants nothing of it.

Activity

  1. superuser404notfound commented on Aug 4, 2026

    @superuser404notfound
    OwnerAuthor

    Fixed on main in d157a705 (PR #297, merged 1c207ef2) and out in 6.6.1, along the lines above. Both consumers are bumped.

    HLSCarriageProbe.classifyFromPlaylists settles the advertised-codec case from the playlists alone, so a master carrying hvc1 / hev1 / dvh1 / dvhe / av01 over a window with no EXT-X-MAP reaches its verdict without a segment byte, AES-128 included. What the playlists cannot settle hands back the segment instead of fetching it, and awaitReadyForDeferredProbe holds that read until readyToPlay, so the only media byte the probe ever spends is spent where a lost connection costs the verdict rather than the mount. A watchdog that disarms first, or an item that never becomes ready, now spends nothing.

    Verification: Issue296CarriageProbeConnectionBudgetTests, 14 tests, all watched failing first, asserting against the fixture origin's request log that no segment is fetched where the playlists decide. Full suite green (463 XCTest, 1479 swift-testing), tvOS and iOS Simulator builds clean, CI green on #297.

    Open here for the device leg on an origin that genuinely caps concurrent connections, which is the one thing neither a loopback nor an uncapped test bed can produce. Two numbers would settle it: a master-advertised HEVC channel reaching the same reroute with no segment request in the origin log at all, and a direct media playlist still firing early, though its verdict now lands after readyToPlay rather than during the mount, so a fraction later than before is expected and a whole tick would be a finding.

    The verdict line names its evidence source now, 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)

    carriage probe: still greps for both, plus the line that announces the deferral.

  2. superuser404notfound commented on Aug 8, 2026

    @superuser404notfound
    OwnerAuthor

    Closing this. The fix is d157a705 (PR #297), released in 6.6.1, and both consumers were bumped at the time.

    What it does, restated for the record: the carriage probe no longer spends a media connection where the playlists already answer. A master that advertises hvc1/hev1/dvh1/dvhe/av01 with a window and no EXT-X-MAP settles from the playlist alone, because a fragmented-MP4 segment requires an EXT-X-MAP (RFC 8216 4.3.2.5), so the absence of one is a normative signal rather than a guess about file extensions. The case that genuinely needs the PMT, a direct media playlist or a master without CODECS, still reads a segment head, but waits for readyToPlay first: a connection lost at t=0 can cost the mount, one spent after readiness can only cost the verdict on an already black session.

    Media connections per shape: HEVC/DV/AV1 master 1 to 0, AES-128 inconclusive to decided early at 0, direct media playlist 1 against the mount to 1 after readiness, H.264 unchanged at 0.

    The only thing left was a confirmation log against a genuinely connection-capped origin, which is a nice-to-have rather than an open defect. The markers are carriage probe: <verdict> from playlist evidence (#293), from segment PMT evidence (#293), and the playlists cannot settle this one, so the segment head waits for readyToPlay ... (#296), and carriage probe: greps all of them. Reopening is cheap if a capped channel ever shows a probe-shaped start failure again.

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