Repository navigation
fix(watch): audio keeps a hole a late burst fills within the stretch - #8982
Conversation
Quest-Claim: 8da1f2e4c072eec9
Browser audio's container consumer ended a missing group as soon as the shared clock reached the group past it. The ring still plays audio trailing the clock within its stretch bound, so a late burst's hole that fills a moment later was thrown away. The consumer now reads the clock less that bound, and the replay harness gives its consumer the same clock the decoder does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…io's hole clock Review: the ring renders the output latency ahead of the shared clock, so the oldest media it still plays is the clock plus that, less the bound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review: before media zero's turn the clock reads zero while the ring already renders, so the output term applies before the clamp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Maintainer decision (2026-11-17, asked in the ✅ Browser audio keeps this PR's rule, the clock less the stretch bound (rejected: main's bare clock with only the replay harness fixed and re-budgeted; the estimate wait the quest recommended). It is the only option with no measured regression: replays are back within budget, live rows are level, and resume is no worse than main. Native and browser keep different rules until moq-dev/moq#8984 settles one. (Written by Claude Opus 5.5 with high) |
…he stretch off Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lead Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 9 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound. The consumer now skips a hole only once the ring would skip its audio anyway, which fixes the actual mismatch between the hole rule and what the ring still plays. It also gives the replay harness the same clock, so the replay rows grade the player as it ships.
Reviewed changes
The whole diff at 3ef3d8e was checked against the ring's real skip and clock-reading logic.
playable(sync, output): Gives the audio consumer a clock that reads the signed position, plus the render lead, minusmax(bound, WINDOW). This matchesring-buffer.ts's thresholdmax(#bound, stretch.window)and the clock reading inbuffer.ts#read(position +currentTime − heard). The decoder's ring bound comes from the samesync.out.delay/maxDelay/in.stretchinputs.AudioBuffer.lead: Tracks the context's observed render lead. It ignores moves under 5 ms, measured against the last reported value, so slow drift still adds up to an update. It falls back to theoutputpeak before the context reports an output position.anchor: ADerivedofsync.anchorand the trail, so a change to the bound or the lead wakes a consumer waiting on a hole.Derivedonly subscribes to its sources once something subscribes to it, so building aplayablefor each consumer leaks no subscriptions.- Replay harness:
replay.tshands its consumerplayable(sync). The new test fails on main's bare clock, and when the stretch is off it still skips the hole. - Docs and quests:
Playhead.now()is now documented as "the oldest media the player still plays". The quest's## Waitingentry on #8910 is gone, and #8910 has merged.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 3ef3d8e4e37e874b7c7d41cc23a3520df4852d86
The stretch-aware cutoff is a better fit than the bare clock, and using observed render lead is right once the clocks are mapped. One gap at js/watch/src/audio/buffer.ts:467–470,494–500: without a valid output timestamp, #read clears the ring's clock mapping, but #observeLead supplies the estimated output latency to the consumer anyway. The worklet then has no shared-clock cutoff while the consumer can discard a still-playable hole. For example, with zero stretch and a 120 ms fallback output estimate, the consumer ends the hole 90 ms before the bare clock reaches it. Gate the lead-adjusted cutoff on a valid mapping, and test the missing-to-valid timestamp transition. Keep the ordinary wall-time hole budget while no mapped clock can judge the audio stale.
Static review; I did not run browser audio or replay tests.

Interim rule for quest/m2/audio-playout/browser-audio-hole-skip.md.
Problem
moq-dev/moq#8799 gave
@moq/watch's audio consumer the shared clock: a missing group ends once the clock reaches the group past it. Natively that rule costbursty155 underruns a minute against 3 (moq-dev/moq#8909), so the quest asked whether the browser regressed too.On the live Chromium rows it did not (tables below). But #8799 never gave the replay harness the clock, so the replay rows were not grading the player as it ships. With the clock, the replays show the quest's exact shape. In the recorded
bursty-aactrace, group 37668 lands 0.8 ms after 37669, and the clock has already passed 37669, so the consumer skips it. That costbursty-aac24 underruns a minute (66.7 ms of gap) andlocal-aac16.1 (42.2 ms), where both had none.The ring plays audio trailing the clock up to its stretch bound (200 ms by default), and only skips past that. So a hole whose successor trails the clock by less than the bound is not yet too late to play.
Approach
playable(sync, output)(js/watch/src/audio/playhead.ts) is the oldest media the ring still plays. That is the clock plus the render lead the ring renders ahead by (ring.lead, the context's observed lead, which follows a fall in output latency at once), less the ring'sbound(the stretch, or a buffered player's lookahead when larger, and never under the ring's 30 ms window). It applies both to the signed clock position before clamping at zero, since the ring renders media zero before the clock reads it. Itsanchoralso changes when the bound or the output latency moves. The audio decoder gives it to the container consumer in place of the bareSync. Video keeps the bare clock.replay.tsgives its consumer the same clock (with no output latency), so the replay rows grade the player as it ships.Playhead.now()andConsumerProps.playheaddocs now say "the oldest media the player still plays", which for video is the clock itself.With a zero stretch the bound is the ring's 30 ms window and the rule is #8799's plus that window.
Validation
All on fedora, loaded by other agents, debug build, seed 7, 40 s rows. Live rows ran in three arms: main (bare clock), no clock (the estimate wait the quest's Plan recommended), and this PR (clock less the bound).
Chromium
bursty: no arm regressed. Every run had 0 tap underruns but one main Opus run (56.5/min) and the last AAC run of this PR (1.7/min), and player underruns 0 to 10.3/min. Chromium's WebTransport lands a burst's out-of-order groups at most 24 ms apart (from a--capturerun), against a 310 to 350 ms target, so the clock rarely passes the successor first.Chromium
congestion, player skips per minute and trimmed ms per minute, one value per run:The first four runs of this PR predate the output-latency term (review round 1), and the fifth includes it.
Noisy. This PR sits between main and no clock on AAC skips, and level elsewhere. A/V lag p95 stayed under 23 ms in every run but one main AAC run (68.6 ms) and one no-clock Opus run (85 ms).
Replays (
just test audio-quality --replays, deterministic):With this PR every replay row matches
budgets.jsonexactly (--enforcepasses, rerun after the 30 ms window and render lead changes), so no budget changes.Firefox resume (moq-dev/moq#8799's repro,
taskset -c 4-5 just test media --media-engines firefox --media-cases rename,pause, 10 runs each, interleaved). Under this host's load many runs failed an earlier window (rename or coded-size growth) for every arm. Of the runs that reachedafter resume:The estimate wait alone brings back #8799's long silence. This PR is no worse than main. These runs predate the output-latency term, which only ends a hole sooner. Main still fails the window on a starved host, as its Nightly does.
Unit test:
replay.test.ts"keeps a hole a late burst fills once the clock passed the group past it" holds groups 250 to 259 and releases them together, with 250 landing 1 ms after the rest. The consumer keeps the hole; with the stretch off it skips it. The test fails on main's bare clock.playhead.test.tschecks the output-latency term, its wake, and the signed position before media zero.just checkpasses, as dobun test src/audio/injs/watch(320 pass) andjust test audio-quality --replays --enforce.Impact
@moq/hang'sPlayhead.now()doc is broadened to "the oldest media the player still plays". Its shape is unchanged, andSyncstill satisfies it.Decisions
Caused by
Follow-ups
None.
Models
Size: M
Implementer: Claude Code, claude-sonnet-5-5, low effort (iterate, S, arm B)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5)
Review
Rewritten by
quest reviewafter each round.Head: 927ba35
Base: origin/main at 44c18eb
Risk: medium,
the base has no RISK.md to name what is always high or customer-facing, so every change is mediumClassified: medium by default
Reviewer: Codex, gpt-6.1-sol, xhigh effort
Session:
01a1eb25-8a05-7c50-8a2a-b6031cc6ebe0, round 3Score: 10/10,
Code inspection confirms the cutoff now follows the observed render lead, with no remaining findings in the incremental changes.Rounds: 6; first round 1 (medium 1); findings 4 (medium 4): fixed 4, refuted 0, open 0
Findings: none
The last round's findings, at 59a59cb:
js/watch/src/audio/decoder.ts:291:Use the observed render lead instead of the latency peak;decoder.ts:291 now uses ring.lead, which buffer.ts:467-470 derives from currentTime minus the same sounding position used to align the worklet clock, independently of the five-second latency peak.