Skip to content

fix(hls): keep empty FIFO writes from signaling EOF - #875

Open
jonluca wants to merge 1 commit into
superuser404notfound:mainfrom
jonluca:fix/fifo-empty-operations
Open

jonluca wants to merge 1 commit into
superuser404notfound:mainfrom
jonluca:fix/fifo-empty-operations

Conversation

@jonluca

@jonluca jonluca commented Oct 25, 2026

Copy link
Copy Markdown

Summary

Writing empty Data into the live-ingest FIFO creates a chunk that a reader drains as zero bytes, even though the queue is still open. The ingest boundary interprets that zero as EOF. Empty writes now leave the queue untouched and complete without waiting for capacity; finished and cancelled queues still reject them.

Nonpositive read lengths now return an error without waiting or consuming bytes, keeping zero reserved for a finished, drained queue. Storage and dependencies are unchanged.

Test plan

  • Apple M4 Max, macOS 27.0.1, Xcode 27.1.
  • Regression coverage exercises a real blocked reader after an empty write, an empty write at capacity, terminal-state rejection, invalid lengths, and preservation of queued bytes. Potentially blocking operations run on dedicated threads and are cancelled for cleanup.
  • Existing FIFO round-trip, chunk boundary, backpressure, EOF, and cancellation coverage included.
  • No source media is needed: the regression is the byte queue's return value before FFmpeg consumes it.
  • Final run: 17 existing XCTest cases and 4 Swift Testing tests (6 parameterized cases) pass, including join-bound sealing. Built with swift test --disable-automatic-resolution --jobs 4, then ran the nearby suites with --skip-build.
  • A separate harness compiled the exact before/after FIFO sources with -warnings-as-errors: upstream returned zero after an empty write; the fixed source kept the reader parked until a byte arrived and then returned one. The invalid-length result changes from zero to -1.
  • Documentation links and git diff --check pass. The package test build retains the existing unrelated CLI unused-binding and interruption-test unused-result warnings.

Checklist

  • Changelog and architecture documentation updated
  • Regression tests in the existing FIFO test file
  • Conventional commit
  • No public API or dependency changes

Copilot AI balanced review requested due to automatic review settings October 25, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The localized guards preserve synchronization and terminal-state handling, with focused regression coverage and no unresolved findings.

No open issues 🎉

What changed in this PR

This PR prevents empty writes to the HLS ingest byte queue from being mistaken for EOF, preserving live-stream reader behavior.

Changes:

  • Accept empty writes immediately without modifying the queue, while still rejecting writes after finish or cancellation.
  • Reject nonpositive read lengths without waiting or consuming bytes.
  • Add regression coverage and document the corrected queue semantics.
File Description
Tests/​AetherEngineTests/​ByteFIFOTests.swift Tests empty writes, terminal states, and invalid read lengths.
Sources/​AetherEngine/​IO/​HLSIngest/​ByteFIFO.swift Adds guards for empty writes and nonpositive read lengths.
docs/​architecture.md Clarifies the byte queue’s write, read, and EOF behavior.
CHANGELOG.md Records the HLS FIFO fix.

Review effort: Balanced

@jonluca
jonluca force-pushed the fix/fifo-empty-operations branch from 4dbf19d to 0571301 Compare October 25, 2026 18:28
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.

2 participants