Repository navigation
fix(live): an ingest seals its TARGETDURATION over the upstream segment its join can pay (#684) - #685
Merged
Conversation
…nt it is delivered in (#684) A live HLS ingest under fastZap re-cuts every upstream segment at its GOPs, so max EXTINF read the GOP (2.000 s) and the upstream's own segment length reached the seal only through the cadence floor, as ceil(segment / 1.5). That division is argued for a measured gap, which is a robust maximum. A segment duration is the period the source delivers at when nothing is late, so a 6 s provider sealed 4: a client patience of exactly one delivery and a 12 s holdback against deliveries that arrive 6 to 9 s apart (the ingest reloads the upstream every half segment). AVPlayer drew -12888, skipped its next playlist reload (4.0 s on macOS, 5.03 s on tvOS) and stalled with the content already listed. The seal is now at least the longest segment the upstream has served, taken whole (LiveEdgePolicy.targetDurationForUpstreamSegment), and the join covers the holdback that follows from it. 2 s upstreams keep TD 2 and a 6 s holdback (AE#447), the self-cut headroom of AE#670 is untouched, and the advertised target duration is still only reported. Measured against Scripts/hls-burst-origin.py (6 s segments, deliveries 3.0 to 9.3 s apart on the loopback), three 180 s runs per arm, alternated: 5 / 4 / 6 times -12888 and 2 / 2 / 3 stalls before, none of either after. Cost: one more upstream segment at the join wherever a segment is longer than 4 s (3.81 s -> 4.98 s to first picture behind an 8 Mbit/s link, not measurable on loopback) and 6 s more standing holdback on a 6 s provider. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ay yet (#684) The live-join guard measures its cushion from the item's currentTime(), and before readyToPlay that is where the loader began fetching, not where playback will begin. On a rejoin placed by EXT-X-START AVPlayer fetches from about 6 s below the target first, so the reading is the lookback itself. Captured on a device: an item placed at 53.908 s read "buffer ahead 4.00s" from a playhead of 48.00 s, every second of it behind the start, and playImmediately was called 36 ms before the item became ready. It was the one item of five in that capture to be forced, and the one its viewer reported out of sync. The decision now requires readyToPlay, says so when the depth alone would have fired, and is asked again at readiness from the playhead the item really starts on. Whether the forced start is what moved sound against picture is not proven: it cannot be observed on macOS, and the loopback never holds long enough to reach the cut. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A viewer saw sound and picture slightly apart after an item rebuild placed mid-segment and together again after the next. The served media measures aligned (beep against flash -0.3 ms on 147 of 148 seconds across an outage), and what AVPlayer's renderer does with it cannot be observed on macOS: an MTAudioProcessingTap on an HLS item is never called. So the session states the facts a device capture needs. Every finalized live segment carries the span of its sound (it opens up to 208 ms before its picture on a TS source, because the cut is taken on the video keyframe), each item start names its segment, the offset into it and that segment's sound against its picture, and the audio route line adds the route's output latency. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…he served URL (#684) hlsfixture publishes on a metronome, so a defect that only exists when a delivery arrives later than the segment is long could not be reproduced. Scripts/hls-burst-origin.py publishes each segment on a schedule (jitter cycle, outage, alternating segment lengths, a link rate shared by all responses) while keeping the mean cadence at the segment duration. play --served-url prints the loopback URL of each native item, so the init segment can be fetched and the cached fMP4 segments read with ffprobe. docs/cli.md carries the measurements of both halves of #684. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#684) Every /media.m3u8 request without an _HLS_msn re-enters the first-serve gate, and AVPlayer opens a session with two of them back to back. With the cushion satisfied both pass at once. On a fastZap bounded start (the window under the holdback, served after its grace) the second request waited out a second grace before init.mp4 was ever asked for. Measured on a three-segment 6 s upstream: first manifest after 2.012 s, first picture at 4.47 s; with the gate open once a manifest has gone out, 2.24 s. This is the "+2.07 s at the picture" AE#594 priced the bounded start at without naming where it came from. Co-Authored-By: Claude Opus 5.5 <[email protected]>
) The readiness sink puts the AE#440 question again when an item becomes ready, but startLiveJoinImmediatelyIfHolding returns silently while a buffer reading is in flight. An item that turned ready during that reading therefore got the stale reading's refusal and nobody asked again. A refusal taken for readiness now checks the item's status as it is and asks once more, once per load. The not-ready refusal no longer falls through to the thin-buffer line, which printed the same depth as its reason for leaving the wait alone and spent that line's once-per-load flag. itemIsReadyToPlay is a required argument, so no caller can decide without stating it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd span too (#684) reportLiveSegmentFinalized returns early when a segment has no recorded start, and the sound span stored for that index at the cut stayed in the map for the life of the producer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pay, under a ceiling (#684) Sealing over the upstream segment asked for a holdback some first windows cannot hold. An upstream that lists three or four 6 s segments joins 18 s and cuts 16 (the last GOP stays open until the next delivery), so against an 18 s holdback the gate waited out the fastZap grace for content that could not arrive: 4.47 s to first picture where 7.25.1 took 0.18 s. The gate now recognises a join that has handed over everything it will and seals the largest value its cut content covers, never under what the seal was without the upstream term: TD 5 there, a holdback the window holds, first picture 0.19 to 0.22 s. The reader states what it joined (joinBacklogSeconds) and the seal line says what was paid of what was asked. The term is bounded by LiveEdgePolicy.upstreamSegmentSealCeilingSeconds (10 s): a 20 s segment taken whole would be a holdback as long as the live-only window, so above the ceiling the seal is what it was. The same constant is the one switch for 10 s providers (at 6 they seal 7 again, as 7.24.0 did). The join sizes its cushion from both terms. .standard is pinned: unchanged up to 6 s segments, sealed whole above. Measured, three 60 s runs per arm and cell, main against this: fastZap 6 s shallow 2 to 3 x -12888 and 1 to 2 stalls -> 1 to 2 x -12888 and no stall; 10 s shallow window closed and item rebuilt in 4 of 6 runs -> none; .standard 10 s item rebuilt in 6 of 6 -> none; .standard 6 s on a deep window first picture 6.3 s -> 0.18 s, on a shallow one unchanged. The drift line names the upstream-segment term as well. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd long segments (#684) api.md said the term was fastZap's and that long-segment providers were untouched by the join; both were wrong. It now states the rule for both profiles, the ceiling, what a join that cannot pay seals instead, the fractional case, the measured matrix and the cost behind a link. The "none" of the first measurement is put as what it is: this origin's number, where the device capture had 10 of 110 gaps above 9 s. cli.md records where the 4 s of a shallow start went, including the second grace the gate charged the second playlist request. Co-Authored-By: Claude Opus 5.5 <[email protected]>
622d6f6 opened the gate for every live session once a manifest had gone out. On a source the engine cuts itself (raw MPEG-TS under fastZap) the second request's grace is part of where the session ends up: without it the first picture comes about 2 s sooner (init.mp4 at 4.1 s instead of 6.1 s on the reviewer's runs) and the session sits up to 2 s closer to the producing edge for its whole life, which nobody has measured on a device. That is AE#594's open question, not this issue's, so that path is back to exactly what 7.25.1 does and only an ingest session, where the second grace waited for content the join had already delivered, keeps the latch. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The re-ask added in fe3b924 only covered a not-ready refusal the depth would have granted. A reading that was both not-ready and thin took the thin-buffer branch and returned without asking again, although it is just as stale: the item it was taken on could not say where it starts. The readiness of the reading now decides the re-ask, whichever line the refusal prints. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…eader's fact (#684) Owner's rule: the join is never extended for the upstream-segment term. loopbackCushionCoverageSeconds is sized from targetDurationForCadence again, as before this branch, so no zap pays an extra upstream segment, and the seal rises only as far as what was joined can pay (targetDurationTheJoinCanPay). That makes the join-bound seal the path of every ingest start, and its trigger was arithmetic: cut content plus one segment against the summed EXTINF, with a 0.5 s tolerance. A playlist whose EXTINF over-reports its media (6.3 for 6 s, measured in review) never added up, sealed the full TD 7 with a 21 s holdback and took the bounded start: 2.23 s to first picture where 7.25.1 took 0.20 s. The reader now states the fact itself: the whole join batch is committed, its FIFO is empty and its consumer is parked waiting for the next upstream delivery (joinIsSpent). The gate has no event for that, so while a join is not yet spent it looks again every 25 ms. Co-Authored-By: Claude Opus 5.5 <[email protected]>
api.md and cli.md described a join one segment deeper and a seal of 6 on 6 s providers. The join is not deepened; the docs now state what is sealed (5 on 6 s segments, 9 on 10 s), what it costs (3 s and 6 s of standing latency, nothing at the join) and what it does not do: on a 6 s provider -12888 still comes (5 and a stall before, 3 and no stall after over 180 s), and .standard on 6 s segments still waits for the next upstream segment as it did. The matrix is re-measured against 7.25.1 on this rule, including the inflated-EXTINF cells and the raw-TS control that shows the AE#594 table unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
#684) joinIsSpent looked at the video reader's FIFO alone. With a demuxed audio rendition the cutter merges two readers on one thread and parks on whichever runs dry first; a rendition whose segments end 0.2 s before the video's runs dry first every time, the video reader is never parked, and the fact never became true. The gate then took the old path with the full seal over a window that cannot hold it: measured on three listed segments as 2.17 to 2.24 s to first picture under fastZap and 10.4 to 10.7 s under .standard, where 7.25.1 took 0.18 to 0.20 s. The fact is now stated for the pump: both join batches committed, and the cutter parked on either empty reader (it holds a packet of the other one it cannot place until the dry one delivers). A companion nobody reads does not count. The gate also asked in the wrong order: cushion snapshot first, spent second. The cutter could append its last segment and park between the two reads, and the seal was paid from the sum without it. The fact is monotone, so it is read first. Tests drive the reader itself against a loopback origin whose responses are released by hand: not spent while its own join batch is still arriving, spent when parked on the audio with video queued, not spent while the audio rendition's join is still arriving. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… slower than the grace (#684) Two shapes the join-bound seal has to be read with. With a companion audio rendition the fact is the cutter's, both join batches committed and either reader dry, measured back at 7.25.1's first picture in six cells. And a join that outlasts the fastZap grace takes the bounded start before it is spent, seals the full upstream-segment value over a window under its holdback and draws a -16832 warning, measured not worse than 7.25.1. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…se (#684) The channel this issue was reported on alternates 6 s and 4 s segments. The join counts seconds back from the newest segment, so its depth depended on which of the two was newest: 4 + 6 + 4 is under the 16 s coverage target and a fourth segment is taken (20 s listed, 18 s cut, seal 6), while 6 + 4 + 6 meets it at three (16 s listed, 14 s cut, seal 4, 7.25.1's value and its stalls). About four tunes in ten landed in the second phase and got none of the fix. When the joined segments differ in length by more than a second and their summed EXTINF is not above the holdback of the seal the longest listed segment asks for, the join takes one segment more, once. On the reported shape that is the short segment the other phase already loads. Uniform upstreams are outside the rule and keep the exact 7.24.0 join (three 6 s or 10 s segments, seal 5 or 9). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…#684) pumpJoinIsSpent takes "the cutter is parked on either reader" to mean that nothing more is cut. That holds only while one thread reads the main and the side reader in turn, which was a comment. It is a debug assertion at the merged read now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…what uniform means (#684) "A 6 s provider seals 5" is true of uniform segment lengths only; the docs now say what a mixed-length upstream gets (6 in both phases, with one additional short segment at the join on about four tunes in ten) and that 3 s providers with 1 s GOPs are unchanged at 2. "The join and the time to the first picture are what they were" is qualified: a host with fewer parallel requests than the join has segments starts later than before (2.79 to 3.08 s against 3.27 to 3.49 s, one request at a time behind 14 Mbit/s). Co-Authored-By: Claude Opus 5.5 <[email protected]>
… nothing else (#684) d4891e3 took one segment more on any mixed-length join that could not pay its seal. That also deepened shapes with no phase asymmetry, on every tune: 10 s / 8 s segments went from three to four (6.19 s to 8.12 s to first picture behind 8 Mbit/s) and 6 s / 6 s / 4 s likewise (3.81 s to 4.98 s), which is the join cost this branch declined for uniform providers. The rule is now what was decided: a tune never loads more than the deepest tune of the same channel already did. The depth is the deepest the 7.24.0 coverage rule takes over the actual tune and the tunes one, two, ... segments earlier whose newest segment this join still takes itself, bounded at one above the tune's own depth. 6 s / 4 s joins four in both phases and seals 6; 10 s / 8 s and 6 s / 6 s / 4 s keep three segments and seal what three pay (8 and 4); uniform upstreams are unchanged. The spread threshold is gone with its float edge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…alone (#684) The docs described "one segment more on a mixed-length join that cannot pay". The rule is narrower: a tune never loads more than the deepest tune of the same channel already did. 6 s / 4 s joins four in both phases and seals 6; 10 s / 8 s and 6 s / 6 s / 4 s keep three segments in every phase (first picture equal to 7.25.1 behind 8 Mbit/s) and seal what three pay, 8 and 4; a shape like 6 s / 5 s keeps a seal that follows the phase. Tables re-measured. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Part A of #684 (the stalls). Part B (sound against picture after an item rebuild) is not confirmed fixed; the issue stays open for a device round.
Cause. Under
.fastZapthe engine re-cuts each upstream segment at its GOPs, so the upstream's segment entered the seal only asceil(segment / 1.5): a 6 s provider sealed TD 4, a patience of one delivery against deliveries 6 to 9 s apart. AVPlayer drew-12888, skipped its next playlist reload and stalled with the content already listed.Change (ingest only).
readyToPlayyet, and is asked again at readiness.#684 itemline per native live item;Scripts/hls-burst-origin.pyandaetherctl play --served-url.Measured (details in docs/cli.md): uniform 6 s, 180 s: 5
-12888and a stall before, 3 and none after; nine 60 s runs: 7 stalls before, none after. Alternating 6 s / 4 s: 0 to 1-12888per run before, none after. 10 s segments: item rebuild in 4 of 9.fastZapand 6 of 6.standardruns before, none after. First picture unchanged on uniform upstreams; on 6 s / 4 s about four tunes in ten load one more short segment (3.47 s to 4.23 s behind 8 Mbit/s). Fewer stalls, not none.Costs. 3 to 6 s more standing latency on the affected providers; hosts with
maxConcurrentSourceRequestsof 3 or less start about 0.5 s later on four-segment joins.Tests: XCTest 708 executed, 0 failures; swift-testing 3990 passed; tvOS and iOS builds succeed.
🤖 Generated with Claude Code
https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS