Repository navigation
fix(watch): release the audio backlog a ring trailing the clock will skip - #8893
Conversation
Quest-Claim: be1c1c2c83afe552
…skip After a route switch the audio ring re-anchors on the incumbent's retained backlog while the live picture moves the shared clock ahead. The ring skips onto the clock, but the decode gate metered the backlog by the ring's own playhead, one floor and window per worklet state report, so on a starved page the audio stayed stalled past the replacement case's switch bound. The gate now counts from the bound behind the clock when the playhead trails it. The replacement case stays quarantined: its quest is rewritten to the remaining cause, a decoder restart at each skipped group trimming 80 ms of warmup. Co-Authored-By: Claude Opus 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 12 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. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 2363828bee89adc17dac6c0f4990c5c7f96009fb.
No actionable defect found in this static pass. Traced the decode gate's new max(playhead, clock - bound) accounting, the 30 ms minimum shared with the ring's skip threshold, reset clearing, and the AudioBuffer clock projection onto the worklet report's context time. The gate keeps its existing playhead behavior without a clock and leaves the pre-start admission path unchanged. The replay harness uses the corresponding end-of-quantum clock reading, and the new tests distinguish within-bound lag from a large re-anchor.
Keeping replacement quarantined is appropriate: this change addresses backlog admission, not the separately documented repeated-gap/warmup loss or loaded-host underruns. Verification limits: GitHub-only source and test inspection; no unit tests, browser runs, replay benchmarks, or loaded-host measurements were run independently. COMMENT only, not approval or a claim that the remaining audio failures are fixed.
There was a problem hiding this comment.
ℹ️ No blocking issues. One inline point: the gate stops short of where the ring lands.
Reviewed changes
This review covers the initial two commits: the decode-gate fix for a ring trailing the shared clock, and the quest and quarantine rewrite.
Backpressurecounts from the skip edge: a started ring's release window now starts atmax(playhead, clock - bound), withboundfloored at the 30 ms stretch window to match the ring's own threshold.AudioBufferclock wiring: the clock reading is sent first. Thenobservegets the clock at the reported playhead's render time (#offset + data.time) on the ring's timeline.- Replay harness parity:
replay.tsdrives the gate withsync.now()and the samebound(...)the ring uses. - Quest and quarantine text:
replacementstays quarantined. The quest and the interop README now name the remaining cause: a group skip restarts the decoder and trims 80 ms of Opus warmup.
buffer.test.ts (35 tests) and replay.test.ts (20 tests) pass locally.
claude-opus-5-5 | 𝕏
The ring skips a trailing playhead all the way onto the clock, not to the bound behind it, so a floor short of the bound left the skip landing on an empty ring that stalled and drained one window per report again. Count from the clock once the playhead trails it past the bound. The two Opus relay-mic replays catch up faster at startup and settle a fraction of a millisecond apart; their lag budgets are re-measured. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found. The gate now stops where the ring lands.
Reviewed changes
This review covers ef3b7ab, which follows up on the prior review's finding.
Backpressurecounts from the clock: a started ring that trails the clock by more than the bound is now metered fromclock. Within the bound, it is metered fromplayhead. This matchesRingBuffer.read, which skips the wholelagonto the clock using the same strict>check.- Regression test for a floor short of the bound: a new
Backpressurecase with a 50 ms floor and a 200 ms bound confirms that the gate releases throughclock + floor + window. The existing tests inBackpressureand inAudioBuffersteering were updated to the new release edge. - Replay budgets re-baselined: in
budgets.json,relay-miclag p50 goes from -0.3 to 0.2 ms and p95 from 9 to 7.7 ms.relay-mic-stallp50 goes from 1.7 to 2.3 ms, in line with the faster startup catch-up the PR describes.
claude-opus-5-5 | 𝕏
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI) · ef3b7ab
No new blocker in the audio gate delta. For a running live ring beyond the bound, the skip targets the clock, limited by what PCM has arrived. The old clock-minus-bound calculation could stop decoding short of that target when the floor was smaller than the bound. The new 48 kHz regression covers that combination and confirms release stops just past the new target; within the bound the gate still uses the playhead. Keep replacement quarantined for the separate repeated-gap and warmup problems. Static review; I did not run Bun, browser interop, or replay budgets.

Claims quest/m0/interop-green/replacement-audio.md. Leaves work: the quest is rewritten to what remains, and the case stays quarantined.
Problem
The
replacementmedia case's audio stalled past its 1039 ms switch bound under CPU load. Traced with batched in-page instrumentation (not in this PR) on failing runs, every slow switch had the same shape:delay + 2 s) oldest first, so the first stale audio frame anchors the fresh clock.Backpressure) metered the backlog by the ring's own playhead: one floor plus a 30 ms window per worklet state report. The ring skipped each window as late on arrival. Catching up 1.7 s took about 20 round trips, which a starved main thread stretched past the bound. One failing lite-07 fallback: the clock jumped 1663 ms ahead, and the playhead then gained about 260 ms per 65 ms of wall time.Approach
Backpressurenow counts from where the ring plays next: the clock once the playhead trails it past the bound, since the ring then skips all the way onto the clock, and the playhead otherwise, since within the bound the ring stretches onto the clock playing everything. What the ring will skip is released at once.AudioBufferpasses it the clock as the ring rendered the reported playhead (offset + state.time, the same reading it sends the worklet) and the ring's bound, floored at the stretch window as the ring's own threshold is. The replay harness (replay.ts) drives the gate the same way.The case stays quarantined. Under the same load a second cause remains, and the quest is rewritten to it. Every group the viewer skips restarts the decoder and trims its 80 ms Opus warmup, so one lost 20 ms group costs 100 ms of audio. When groups go missing more often than every 80 ms, nothing plays at all: one fallback stayed silent past its bound. The rest are underruns of the case's fixed 50 ms delay on a saturated host, which its sibling cases share.
Impact
Backpressure(@internal) gains an optionalboundon its constructor andsetLatency, and an optionalclockonobserve.Alternatives
Validation
just test media --media-cases replacementon fedora, pinned with busy loops to 6 or 8 cores (taskset), and unpinned with other agents holding the host near saturation. Each round ran the old and newbuffer.tsback to back.audioStalled:true.audio tonecheck about one run in ten at this load. Under the same pinned load, the default media run withoutreplacementfailedaudio rendition switch back1 of 4. Main's own scheduled run 43729752212 failedaudio tone: after resume(69/81).Backpressure, andAudioBuffer's clock wiring) fail without the change. One covers a floor short of the bound (50 ms against 200 ms), where an earlier head counting fromclock - boundreleased only through 1860 ms of a 2000 ms clock, so the skip landed on an empty ring and stalled (Pullfrog's finding).just test media --media-cases replacement: passes. The loaded before/after numbers above were measured on the earlierclock - boundhead; the fix releases strictly more after a skip.just test audio-quality --replays --enforce: within budget. Counting from the clock moves the two Opusrelay-microws, re-budgeted:relay-miclag p50 -0.3 to 0.2 ms and p95 9 to 7.7 ms,relay-mic-stallp50 1.7 to 2.3 ms. Per-sample traces show the difference is the startup catch-up from the retained backlog, which converges faster (lag at 1.75 s: 46.7 against 74.8 ms; accelerated audio 233 against 250 ms) and settles a fraction of a millisecond apart; trims, skips, underruns, and stalls are unchanged.just check,just ci: pass. The final build passed 3 of 3 loaded runs of the case.Decisions
Taken on the maintainer's behalf, for review:
replacementquarantined, with the quest rewritten to the gap-warmup cause, instead of lifting it now. Lifting now would add about a 10% flake on a loaded host. On an idle CI host it would likely pass, as it did on 11-14 and 11-15.relay-micandrelay-mic-stallreplay lag p50 rather than treat the 0.6 ms rise on the stall row as a regression: the README calls a rising steady-state lag a regression, but the shift is the residual after a faster startup catch-up, andrelay-micmoved toward zero.Follow-ups
None new: quest/m0/interop-green/replacement-audio.md is rewritten to the remaining work, with the recommendation in its Plan.
Seen on main, not this quest's: scheduled run 43729752212 (11-15) failed
datagram_tracks_javascript(panic atdatagram_tracks.rs:33),go -> jstimeouts (36 to 37 s of 30) in both matrices,datagram rust -> js-native-node/bun (missing groups or clean end)on moq-transport, and theafter resumetone above.Caused by
Models
Size: M
Implementer: Claude Code, claude-opus-5-5 (iterate, S, arm A)
🤖 Generated with Claude Code
(Written by Claude Opus 5.5 with medium effort)
Review
Rewritten by
quest reviewafter each round.Head: ef3b7ab
Base: origin/main at 3e7987a
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, high effort
Session:
01a1e42e-11dd-74b1-9bc2-17934c06ab6f, round 2Score: 8/10,
No actionable regressions found: the updated decode gate matches the ring’s skip destination and adds targeted regression coverage, though builds and tests were not run as instructed.Rounds: 2; first round 0; findings 0: fixed 0, refuted 0, open 0
Findings: none