You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(hls): gate each segment request on FIFO headroom - #832
A persistent HTTP/1.1 HLS reader can start the next segment while its FIFO is already full. When the final offered body chunk crosses the 16 MiB ceiling, pending becomes empty and stream returns without entering append's backpressure wait. The next iteration then opens another request. This is the production boundary behind the existing macOS failure observed on #825, whose subtitle changes do not touch this path.
Check FIFO admission before each sequential segment request. The current body still downloads to completion, preserving #816's slow-origin behavior and keeping the connection idle between requests. The wait stays on the existing BlockingWork producer executor. Consumption, seek, close and cancellation wake it; failed/closed or superseded generations cannot proceed from the wait. No public API, timeout, default transport or dependency changes.
Keep the original mid-segment full-buffer regression. Add a final-chunk witness through the real loopback origin, ingest FIFO and transport, with four outcomes (consume, seek, close, cancel) and both clear and AES-128 next segments. It checks no early segment/key request, complete bytes after resume, the correct post-seek marker, one connection/one request in flight and no late request after retirement. Blocking test reads run on detached test threads and cancellation closes the reader.
Upstream context: #732 and merged #816 implement streaming and segment-boundary backpressure; this fixes the no-pending-remainder gap in that implementation. Affected production/test code matches main 151322d1b843b4414a0fcffa9ed44e8b3a9d087e. This independent fix does not change #825's bitmap-subtitle scope.
Validation on Apple Silicon Mac17,3, macOS 26.7.1 / Swift 6.4:
With production code unchanged, all eight new argument combinations fail (14 assertions). With the admission guard, all eight pass under the strict cooperative pool.
The existing 18 HTTP/1.1 XCTest regressions pass, along with the eight new combinations in the normal pool.
Full serial default-traits suite passes: 795 XCTest tests (1 existing skip), 4,615 Swift Testing tests across 634 suites.
Documentation links and git diff --check pass.
Host executables are signed and verified with an Apple Development identity; linker ad-hoc signing is disabled.
Other platforms and all-traits coverage are left to CI. The fixture is synthetic MPEG-TS; no new physical-device playback acceptance is claimed.
Thank you for this, and for the deterministic test. Merged into main as af85d85d (your commit 02ae2c64, rebased onto current main with authorship kept), which is why this PR shows as closed rather than merged.
To be transparent about the overlap: about nine hours after you opened this, eca55f0b closed the clear-segment half of the gap on its own, by waiting for room at the end of stream (in 7.40.0). Your gate at the top of the loop goes further. When a segment is AES-128, its bytes reach the FIFO whole through append(), which waits only before it appends. On 7.40.0 an encrypted segment that filled the FIFO therefore still let the next key and segment request out over the ceiling. Your per-request check holds that case too. On the rebase it replaces the end-of-stream wait, so there is one admission point instead of two.
One addition on top, 3dba978f: the admission test now also runs with encryption starting at segment 1, so the segment that fills the FIFO is an encrypted one. That variant fails on the 7.40.0 reader (seg2 requested over the ceiling) and passes with your gate. The full suite is green (XCTest 779, swift-testing 4640).
It will ship in the next release, and the changelog credits you.
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
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.
A persistent HTTP/1.1 HLS reader can start the next segment while its FIFO is already full. When the final offered body chunk crosses the 16 MiB ceiling,
pendingbecomes empty andstreamreturns without enteringappend's backpressure wait. The next iteration then opens another request. This is the production boundary behind the existing macOS failure observed on #825, whose subtitle changes do not touch this path.Check FIFO admission before each sequential segment request. The current body still downloads to completion, preserving #816's slow-origin behavior and keeping the connection idle between requests. The wait stays on the existing
BlockingWorkproducer executor. Consumption, seek, close and cancellation wake it; failed/closed or superseded generations cannot proceed from the wait. No public API, timeout, default transport or dependency changes.Keep the original mid-segment full-buffer regression. Add a final-chunk witness through the real loopback origin, ingest FIFO and transport, with four outcomes (consume, seek, close, cancel) and both clear and AES-128 next segments. It checks no early segment/key request, complete bytes after resume, the correct post-seek marker, one connection/one request in flight and no late request after retirement. Blocking test reads run on detached test threads and cancellation closes the reader.
Upstream context: #732 and merged #816 implement streaming and segment-boundary backpressure; this fixes the no-pending-remainder gap in that implementation. Affected production/test code matches main
151322d1b843b4414a0fcffa9ed44e8b3a9d087e. This independent fix does not change #825's bitmap-subtitle scope.Validation on Apple Silicon Mac17,3, macOS 26.7.1 / Swift 6.4:
git diff --checkpass.Other platforms and all-traits coverage are left to CI. The fixture is synthetic MPEG-TS; no new physical-device playback acceptance is claimed.