Repository navigation
fix(moq-video): a failed drain keeps its boundary, colour switches stay bounded, and capture drains its encoder - #9061
Conversation
Quest-Claim: 4005c6eda7b94f8d
…s stay bounded Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uity 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 7 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 — each fix lands at the seam that owns the invariant (the consumer's drain, the decoder's switch queue, the capture loop's encoder lifetime), and every one is reproduced by a probe backend that fails the way a real codec does rather than by a mock.
Reviewed changes
- A failed drain keeps its boundary (
decode/consumer.rs): theGapandEndarms hold the drain's result, queue the drained pictures, then the boundary, arm recovery for a gap, and only then report.drain()now collects after a failed flush and the track-end branch shares it, so readied pictures are never lost behind a boundary. - Threaded decode sink collects after a failed flush (
decode/sink.rs): the worker collects before replying, so a flush that readies a picture and then fails no longer leaves it to surface behind the next boundary. - Colour switches stay bounded (
decode/decoder.rs): a switch is recorded only once the backend accepts the keyframe, switches at or past a new keyframe's timestamp are dropped, and the queue is capped atSWITCHES = 32with the oldest applied early. - Capture drains its encoder (
encode/capture.rs): every normal exit from the inner loop now callsProducer::discontinuity()— except after a cancelled encode, which poisons the sink — and capture follows a rendition the drain moved to a new track. - Test-only plumbing:
probe-failing-flush,probe-pipelined(an OpenH264 wrapper holding one access unit), shared H.265 SPS fixtures, andprobe-holdingaccepting H.265.
Verified locally: the full moq-video lib suite passes with capture,openh264 (291 passed, including all four new tests), the crate's tests also compile with capture alone, and rustfmt --check is clean. I also read every in-tree decode backend's flush to confirm that receive() after a failed flush is safe (each either discards its tail or reports a clean error, and the worker only poisons on a cancelled call).
deepseek-v4.1-flash | 𝕏

Summary
Closes the
video-decode-lifecyclequest from the 2026-11-17 pre-cut audit. Each finding was reproduced with a test before it was fixed.decode/consumer.rs). At a Gap or End,self.drain().await?returned early and lost the consumed marker: noRead::GaporRead::End, and no leading-picture recovery after a gap. Now the drain's result is held while the drained pictures, then the boundary, get queued and recovery gets armed. Only after that is the error returned.drain()also queues what a failed flush readied, so the track-end branch now shares it instead of keeping its own copy.decode/sink.rs). Found while reproducing the first bug. A flush that readied pictures and then failed left them in the backend. The next decode then pushed them out behind the boundary, or they were lost at track end.decode/decoder.rs). A switch is now recorded only after the backend accepts the keyframe; a refused one yields no picture to reach the switch. A new keyframe drops the switches at or after its timestamp, which only backwards timestamps leave behind. The queue is capped atSWITCHES = 32, the same sizing as the consumer'sARRIVALS. At the cap the oldest switch is applied early instead of kept.encode/capture.rscapture_loop, after merging moq-dev/moq#8964). A source end, a resize, and an on-demand release used to callProducer::release(), which drops the encoder without flushing. Now they callProducer::discontinuity(), which drains the tail into the track and then marks the break, and still marks it if the drain fails. If a drained frame moves the rendition to a new track, capture follows it there, as the in-loop path already does.release()is now used only after an encode was cancelled mid-call, since the sink refuses every call after that. Its doc now says so.Test-only additions:
probe-failing-flush, a decode probe whose flush readies its held picture and then fails.probe-pipelined, an encode probe that wraps OpenH264 and holds back one access unit, like Media Foundation. The H.265 SPS fixtures moved tovui.rsconstants so the decoder test can share them. Theprobe-holdingbackend now also accepts H.265.Public API: none. Wire: none.
Decisions
Validation
a_failed_drain_keeps_its_endanda_failed_drain_keeps_its_gap_and_recoveryfailed before the fix: the Gap and End were lost, leading pictures 2800 and 2900 leaked through, and the track-end tail was lost. They pass after it.color_switches_stay_bounded: alternating spaces on 100 keyframes no picture comes back for stay at 32 entries; backwards timestamps keep at most one.a_source_end_publishes_the_frames_the_encoder_holds: with the drain reverted, it fails in 38ms ("the encoder's last frame was never published"). With the drain it passes.clock::a_drained_frame_that_moves_the_track_is_followed(from review round 1): without following the move, it fails fast because capture ends while watching the old track. With it, it passes.just test -p moq-video --features capture,openh264: 362 passed. Swappingdiscontinuity()back torelease()fails both capture tests. Removing the track-follow failsa_drained_frame_that_moves_the_track_is_followed.just check: passed. Its first run hit the knownlibmoq test::server_accepts_a_sessionflake, which passed on the re-run.Caused by
drain().await?at a Gap or End dropped the consumed marker on error (found by reviewer, the pre-cut audit)release()(found by reviewer, the pre-cut audit)Follow-ups
None.
Models
Size: S
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)
Review
Rewritten by
quest reviewafter each round.Head: 359274b
Base: origin/main at 928d5f3
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, medium effort
Session:
01a1ed14-ed3b-78f1-9c13-674e1017b854, round 3Score: 10/10,
The merge preserves encoder draining, break marking, and demand tracking through the new Producer API; source-only review found no new issues, and no builds or tests were run.Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none