Repository navigation
Three live-path fixes from the #168 investigation (#177) - #184
Merged
Merged
Conversation
…177) The ingest segment loop awaited each fetch fully before starting the next, so every segment paid a connection + TTFB round-trip with no bytes flowing and the producer could not get ahead of the playhead on high-bitrate live streams (4K50 HEVC/TS at ~13 Mbps: cache stuck at ~5 segments, videoPtsAdvance at roughly half of wall-clock). Segment fetches now run through a bounded prefetch pipeline: up to 4 fetches (and AES-128 decrypts) in flight concurrently, committed to the FIFO strictly in playlist order. First-segment classification, discontinuity logging, and demuxer pacing via the blocking FIFO write are unchanged; the window is anchored at the commit point so in-memory segment bytes stay bounded to the window size even when the head segment is slow. Reported with a field-verified design by kskchaitanya1993. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
The live no-cut watchdog retuned on wall-clock since the last finalized segment alone. A source delivering just below real time (a 6 s segment that simply has not fully arrived inside the 10 s timeout while packets keep flowing) was classified a cutter wedge and force-retuned, which re-joins behind the live edge, drains the buffer, and loops. The wedge classification is now gated on PTS advance via the pure decision noCutStallAction: when video PTS advanced at least 2 s in the window, the watchdog holds and re-arms (window counters and anchor reset, bounded to 6 consecutive holds) instead of exiting for host retune. A genuine SSAI ad-pod wedge reads at full rate with frozen video PTS and still exits immediately, so the #167 halt-latch behavior is preserved; the source-starvation classification is unchanged. Reported with a field-verified design by kskchaitanya1993. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
…177) Anamorphic (SAR != 1:1) content on the software path rendered at coded dimensions (a thin strip): AVSampleBufferDisplayLayer reads display aspect from the CMVideoFormatDescription PAR extension, and while the decoder attached SAR to each pixel buffer (#23), the renderer's format-description cache key omitted PAR, so whatever the first frame carried was frozen for the whole stream. Garbage AVCodecContext SARs (1088:1 seen in the field) and per-field oscillation on interlaced content had no gate. The decoder now resolves SAR frame -> codec context -> stream (first sane value wins, both axes gated to 1...256), latches the first non-square SAR per stream so field-alternating sources cannot flicker the display geometry, and clears stale attachments on recycled pool buffers. The renderer keys its format-description cache on the PAR attachment, so a PAR change at identical geometry creates a fresh description instead of reusing the frozen one. Reported with a field-verified design by kskchaitanya1993. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #177 (left open for the reporter retest). All three issues verified against main and fixed at the layer the reporter identified; each fix ships with regression tests.
1. Bounded parallel segment prefetch (ingest)
HLSLiveIngestReader.runIngestawaited eachfetchSegmentfully before starting the next, so every segment paid a connection + TTFB round-trip with no bytes flowing. On a 4K50 HEVC/TS stream (~13 Mbps) the producer could not get ahead of the playhead (cache stuck at ~5 segments).Segment fetches now run through a bounded prefetch pipeline: up to 4 fetches (and AES-128 decrypts) in flight, committed to the FIFO strictly in playlist order. Classification-before-first-FIFO-byte, discontinuity logging, and demuxer pacing via the blocking FIFO write are unchanged; the window is anchored at the commit point, bounding in-memory bytes to the window size. Covered by
Issue177IngestPrefetchTests(loopback origin asserting both the concurrency high-water mark and byte-exact playlist ordering under out-of-order completion).2. No-cut watchdog gated on video PTS advance (producer)
The watchdog retuned on wall-clock since last finalize alone; a slow-but-healthy source (segments finalize slower than the 10 s timeout while video PTS keeps advancing) was classified a cutter wedge and force-retuned, re-joining behind the live edge and draining the buffer each cycle.
New pure decision
noCutStallAction: wedge-classified stalls with >= 2 s video PTS advance in the window hold and re-arm (bounded to 6 consecutive holds) instead of exiting for host retune. A genuine SSAI ad-pod wedge (full read rate, frozen video PTS) still exits immediately, so the #167 halt-latch and 503 behavior are preserved; the source-starvation classification is unchanged. Covered byIssue177NoCutHoldTests.3. SAR latch + PAR-keyed format-description cache (software path)
The decoder attached SAR to each pixel buffer (#23), but the renderer's
CMVideoFormatDescriptioncache key omitted PAR, so the first frame's state was frozen for the whole stream and anamorphic content collapsed to coded dimensions. GarbageAVCodecContextSARs (1088:1) and per-field oscillation had no gate.The decoder now resolves SAR frame -> codec context -> stream (first sane wins, axes gated to 1...256), latches the first non-square SAR per stream, and clears stale attachments on recycled pool buffers; the renderer keys its format cache on PAR. Covered by
Issue177SARLatchTests(including the frozen-description regression against a live renderer instance).Verification
swift test)swift build -Xswiftc -strict-concurrency=completecleanxcodebuildclean (CI parity)🤖 Generated with Claude Code
https://claude.ai/code/session_01NAPCg4tCDdSqkK6tPkNptw