Repository navigation
test(interop): the native JS audio reader joins at the live edge and drains before a gap - #9811
Conversation
…ad.md Quest-Claim: b1e97dd7536e1271
…drains before a gap The js-native audio reader joined its live range at `min = max = 5s`, so its first group (and each backlog group after it) started less than one group from its own staleness budget. A Node reader starved on CPU, still draining that backlog when the live edge moved on, lost the group as "exceeded the subscription max delay budget", which the consumer reports as a gap. It now joins at the live edge with the same 5 s budget, built by `Container.subscription` from the one `Delay` the consumer reads too. A gap also no longer fails a reader whose queued frames already hold the requested audio: it flushes the decoder first, as libav's async output lags what was read under load. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. WalkthroughThe JS-native audio test client now uses a 5-second subscription delay for both the subscription and consumer. When the audio feed encounters a gap, it flushes the decoder and returns if the requested sample count has been decoded. Otherwise, it raises the existing gap error. Two investigation notes about the reported audio-gap scenario were deleted. Merge Risk:
|
Problem
Under CPU load,
rust -> js-native-nodefailed its audio check with a gap (audio gap after 4096 samples, at 2090666.333us for 917333.667us, 1 of 270 Rust cells in a full-width loop). The relay had delivered the group whole and the reader logged no skip warning.Reproduced by pinning the Node subscriber to one CPU shared with 3
stress-ngworkers and looping the Rust media round: 6 of 40 rounds failed (15%). A log line on the consumer's truncated-group branch named every failure: the start group of the read failed withgroup exceeded the subscription max delay budget(StreamCode.Old), set by@moq/net's#expirewhile the group still had frames in flight to the starved reader.The cause is the reader's subscription, not the library. It joined its live range at
{ min: 5s, max: 5s }. A join that reaches back the whole budget starts on the group coveringedge - 5s. That group goes stale once the live edge passes its successor's start plus 5 s, which is less than one group (1 s) after the join. Each backlog group after it has only one more second of slack. A reader slower than real time through that backlog loses the oldest group to its own budget. The consumer then correctly reports it as a gap. In every failing round, the group lost was the first one the relay served. The library did what the subscription asked. The client's comment says the 5 s budget exists for a reader that falls behind, but the join used all of it up before the first read.The original AAC failure also matches
quest/m0/interop-js-native-gap-drain.md. The edge of 2090666 us is past what the 4096 decoded samples cover. The reader had read ahead of libav's async output, so the frames it had already queued may have held the 600 ms it needed when the gap arrived. This PR does both quests.Approach
test/interop/clients/js-native/subscribe.ts:AUDIO_DELAY = { min: 0, max: 5s }builds the subscription throughContainer.subscriptionand is the consumer'sdelay, so the two cannot disagree. The reader needs only 600 ms of audio, and now has the whole 5 s budget to fall behind in.want. tone.py judges only that window.Deletes both quests.
Impact
None. This changes only the test client: no public API, no wire format.
Caused by
maxDelay: 5s, which reached back the whole budget and left the join's first group under one group from stale (found by check)Decisions
@moq/net's max-delay expiry while its frames are in flight. The library cannot tell a starved event loop from a stalled wire, and for a real player those frames are past their playout deadline. Rejected: a unit test that fails first in@moq/hangor@moq/net. No library branch is wrong, so the failing-first test is the starved interop loop below.min: 0). Rejected: keepingminand raisingmax, which is a longer timeout and is clamped by the Rust publisher's 5 s max-age anyway. Rejected: aminjust undermax, which is an arbitrary margin.min = max. They have the same narrow first-group slack, but they decode natively and showed no failures in 540 cells. For themminis also the playout delay that sets how long a hole is waited for, so changing it changes what they test.min = max = 1s. A video gap is not a failure: the reader only needs one non-empty frame.Validation
.tmpcopy ofinterop.shloopingstart_publisher/run_roundforrust -> js-native-node, the subscriber pinned withtaskset -c 0,stress-ng --cpu 3 --taskset 0): 6/40 failed before, 0/60 after. Every passing round includes tone.py's judged audio. P(0/60 at 15%) is about 6e-5.just test interop --publishers rust,python,go,cpp,js --subscribers js-native-node,js-native-bun: all passed, including the swapped-tone negative control, the finishes, and the tails.just ciandjust checkpassed.Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-opus-5-5, unknown (arm A)
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.The change deletes two quest plan files and edits one interop test client (test/interop/clients/js-native/subscribe.ts) to flush the decoder before failing on a gap; if it is wrong, only the js-native interop test cell could flake or wrongly pass, and no shipped package, API, wire format, or consumer reads any of it, so a revert undoes it fully.878ecd9d-ede9-4c80-9967-0a596c8a8b9d