Skip to content

fix(io): the VOD packet cache covers audio packets that carry no duration - #775

Merged
superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
pkajaba:fix/readahead-durationless-audio
Oct 15, 2026
Merged

superuser404notfound merged 1 commit into
superuser404notfound:mainfrom
pkajaba:fix/readahead-durationless-audio

Conversation

@pkajaba

@pkajaba pkajaba commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Standalone. Base: main. Independent of the FEL stack.

Summary

Matroska TrueHD reaches the software read-ahead with no packet duration and millisecond timestamps that repeat (0.83 ms frames on a 1/1000 time base). SoftwarePacketCoverage.insert rejects a zero duration, so audio coverage stayed empty, the combined A/V frontier was nil, and no seek ever hit the packet cache: every seek, even back to a spot just played, refetched from the source and the queue ran dry for seconds.

Audio arrives in presentation order, so a duration-less packet now proves coverage up to the next packet's timestamp, as long as the gap is at most 0.5 s (a larger one is a hole). Packets with a duration are unchanged.

Measurements

Apple TV 4K, a 4K Matroska title with TrueHD 7.1 served over HTTP, 5 seeks per run: cache hits went from 0 of 10 to 5 of 5 in every run. AC-3 and video-only versions of the same file already hit 10 of 10.

How it was tested

  • SoftwarePacketReadAheadAudioCoverageTests: duration-less repeating-millisecond audio makes a retained seek a cache hit; a gap over 0.5 s is not bridged; audio with durations is unchanged. The first test fails without the change.
  • Scripts/test-software-packet-read-ahead.sh and the read-ahead suites pass. Full suite (on main with this PR, RA2 and the FEL stack merged): 4786 tests in 648 suites plus 17 XCTest pass under swift test; under LIBDISPATCH_COOPERATIVE_POOL_STRICT=1 swift test --skip-build --disable-xctest all pass except one run of ItemSwapStillTests (its fixture writer failed under load; 3 of 3 reruns pass, and the stack does not touch it).
  • CHANGELOG "Fixed" entry.

…tion

Matroska TrueHD reaches the software read-ahead with no packet duration and millisecond timestamps
that repeat (0.83 ms frames on a 1/1000 time base). SoftwarePacketCoverage.insert rejects a zero
duration, so audio coverage stayed empty, the combined A/V frontier was nil, and no seek ever hit
the packet cache: every seek, even back to a spot just played, refetched from the source.

Audio arrives in presentation order, so a duration-less packet now proves coverage up to the next
packet's timestamp, as long as the gap is at most 0.5 s (a larger one is a hole). Packets with a
duration are unchanged.

Apple TV 4K, 4K Matroska with TrueHD 7.1 over HTTP, 5 seeks per run: cache hits went from 0/10 to
5/5 in every run; AC-3 and video-only already hit 10/10. The new test fails without the change.
@superuser404notfound

Copy link
Copy Markdown
Owner

Merged as 9480b14, thanks. The earlier close was a slip during the #765 merge, not a rejection. Only conflict was CHANGELOG (kept both entries). Checked locally: the new suite passes, the TrueHD test fails against the pre-change SoftwarePacketReadAhead.swift, and Scripts/test-software-packet-read-ahead.sh passes. Every source-epoch bump goes through clearSourceMetadataLocked, so lastAudioPTS cannot bridge across a seek.

@pkajaba
pkajaba deleted the fix/readahead-durationless-audio branch October 16, 2026 23:32
superuser404notfound pushed a commit that referenced this pull request Oct 21, 2026
…me size is wrong, changelog for #828

The sample-clock model skipped the duration-less fallback whenever codec
geometry was admitted. A declared frame size that understates the packet
(implicit HE-AAC: codecpar 1024, packets 2048) fails the join on every
packet, so a duration-less track covered nothing and every seek refetched,
the regression #775 fixed for TrueHD. The fallback now applies whenever the
join fails. Also keeps #823's overflowing successor case as a regression.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01WJcXkGQrMiBPixVEFTSBJS
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