Skip to content

fix(live): the carriage probe spends playlists against the mount, and a segment only after it - #297

Merged
superuser404notfound merged 1 commit into
mainfrom
fix/296-carriage-probe-connection-budget
Aug 4, 2026
Merged

superuser404notfound merged 1 commit into
mainfrom
fix/296-carriage-probe-connection-budget

Conversation

@superuser404notfound

@superuser404notfound superuser404notfound commented Aug 4, 2026 •

Copy link
Copy Markdown
Owner

Part of #296. The issue stays open for the device leg on a real connection-capped origin.

The #293 probe classifies a live source's carriage from its playlist and the head of its first segment. That segment read starts in NativeAVPlayerHost.load, concurrently with the native mount, and on an origin that caps concurrent connections per token (the IPTV norm, one or two) it is a second media connection competing with the mount. Playlist fetches are generally not what such caps count. The shapes the gate admits, an fMP4-only advertised codec or no master evidence at all, are precisely the channels where the cap bites, so this could land as an intermittent failure to start on the channels the probe exists to speed up, and it would read as a flaky origin rather than as the probe.

Two defects, neither of which is "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 with no EXT-X-MAP is therefore that codec in MPEG-TS, settled from a CODECS attribute AVFoundation has already parsed plus one playlist fetch. HLSCarriageProbe.classifyFromPlaylists settles that outright now. AES-128 no longer blocks the branch either: the PMT is not what is being read there, the ingest decrypts that carriage, and the alternative for those channels was the full grace ending in the same reroute.

It reads it at the one moment where losing the race is expensive. The verdict cannot be acted on before readyToPlay regardless, since it feeds the watchdog and the watchdog arms there. Running the read against the mount buys nothing but a head start on the probe's own latency. What survives the playlist stage, a direct media playlist or a master without CODECS, is where the PMT is the only evidence separating HEVC in MPEG-TS from H.264 in MPEG-TS: dropping it would either pull working H.264 channels off the native path or return that case to indefinite black. So the read stays, and waits for readyToPlay, where a lost connection can only cost the verdict on a session that is already showing black. A session whose watchdog disarms first, or which never becomes ready, now spends no media byte at all.

Media connections per channel shape:

shape before after
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 saving stays about 3.5 s of the 4 s grace: the deferred verdict lands inside the first tick or two.

Verification

Issue296CarriageProbeConnectionBudgetTests, 14 tests, all watched failing first. They pin the playlist evidence rules (advertised fMP4-only codec, EXT-X-MAP, AES-128 vs SAMPLE-AES, an empty window, no CODECS) and assert on the origin's request log that no segment is fetched where the playlists settle it. Full suite green: 463 XCTest (1 skipped) plus 1479 swift-testing. tvOS Simulator build clean.

Raised by @kskchaitanya1993 on #293 after the device leg, as a design concern against connection-capped origins rather than a reproduction.

… a segment only after it

The #293 probe reads the head of the first segment to classify its PMT, and it
starts that read in `load`, concurrently with the native mount of the same
stream. Origins that authenticate per token routinely cap concurrent
connections at one or two, and what such a cap counts is media fetches, not
playlist fetches. The shapes the probe's gate admits, an fMP4-only advertised
codec or no master evidence at all, are exactly the live channels where that
cap bites, so the probe could take the slot the mount needed and land as an
intermittent failure to start on the channels it exists to speed up.

Neither defect behind that is "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), so a master that advertises
hvc1/hev1/dvh1/dvhe/av01 over a window that carries no EXT-X-MAP is that codec
in MPEG-TS, settled from a `CODECS` attribute AVFoundation has already parsed
plus one playlist fetch. `HLSCarriageProbe.classifyFromPlaylists` settles that
case outright now, and AES-128 no longer blocks it: the PMT is not what is
being read there, the ingest decrypts that carriage, and the alternative for
those channels was the full grace ending in the same reroute.

And it reads it at the one moment where losing the race is expensive. The
verdict cannot be acted on before readyToPlay in any case, because it feeds the
watchdog and the watchdog arms there, so running the read against the mount
buys nothing but a head start on the probe's own latency. What is left after
the playlist stage, a direct media playlist or a master without CODECS, is
where the PMT is the only evidence that separates HEVC in MPEG-TS from H.264 in
MPEG-TS, and dropping that distinction would either pull working H.264 channels
off the native path or return the case to indefinite black. That read now waits
for readyToPlay, where a lost connection can only cost the verdict on a session
that is already showing black, and a session whose watchdog disarms first, or
which never becomes ready at all, spends no media byte.

Media connections per channel shape: an advertised HEVC/DV/AV1 master goes from
one to none, an AES-128 one from none-and-inconclusive to none-and-settled, a
direct media playlist keeps its one but no longer spends it against the mount,
and an H.264 master still spends nothing. The saving stays about 3.5 s of the
4 s grace, since the deferred verdict lands inside the first tick or two.

Verify: `Issue296CarriageProbeConnectionBudgetTests`, 14 tests, all watched
failing first, pinning the playlist evidence rules and asserting on the origin's
request log that no segment is fetched where the playlists settle it. Full suite
green (463 XCTest, 1479 swift-testing), tvOS Simulator build clean.

Raised by @kskchaitanya1993 on #293 after the device leg, as a design concern
against connection-capped IPTV origins rather than a reproduction.

Part of #296, which stays open for the device leg.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01HX5zV3Fcf7Nzq4DYGdXvQE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant