Skip to content

fix(hls): gate each segment request on FIFO headroom - #832

Open
orut34iop wants to merge 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/fix-hls-segment-boundary-backpressure
Open

orut34iop wants to merge 1 commit into
superuser404notfound:mainfrom
orut34iop:codex/fix-hls-segment-boundary-backpressure

Conversation

@orut34iop

Copy link
Copy Markdown
Contributor

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.

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