Repository navigation
fix(webrtc): a WHEP pull's stop ends its tracks, and a timeline step is a break - #9032
Conversation
Quest-Claim: 9e40f5b0e689acc8
…is a break A pull cancelled at shutdown dropped its sink, and the origin's teardown dropped the logical tracks its fronts served, each unfinished. The sink aborts its tracks and catalog on drop, and a dropped front ends its logical tracks as closed. The ingest's timeline steps a track forward once the sender reports replace arrival time. The export read that unmarked step as the source's clock running past the drift limit, and failed the chain. A step is now taken where a group opens, and the track publishes a discontinuity first. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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 29 seconds. 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.
Important
A video step that lands on a delta frame waits for the next keyframe, and nothing asks for one. A sender that sends keyframes only on request leaves video out of sync with audio for the rest of the session.
Approach: sound. Marking the sender-report step with the existing marker group fixes the cause the PR found (an unmarked step the jitter buffer read as drift) instead of loosening the buffer. The two Drop impls close the cancelled-future paths that left tracks unfinished. The one gap is how long a deferred video step can wait.
Reviewed changes
All 13 files at bfc3770: the ingest clock's step detection, the discontinuity plumbing through the codec bridges, and the two teardown Drops.
IngestClock::normalizestep detection. A forward jump of more than 20 ms past where the track's timeline would continue counts as a step. Audio frames and keyframes take it and are flagged asstepped. Delta frames stay on the old timeline.- Discontinuity plumbing. A new
MediaSink::on_discontinuitygoes throughBridges, each codecBridge, andDeferredVideo(a no-op until a frame creates the importer) to the importer's existing marker-groupdiscontinuity(). impl Drop for IngestSink. It aborts the bridges and catalog withCancel. This does nothing afterfinish: the bridge map is already empty, andcatalog::Producer::abortreturns early onceclosedis set.impl Drop for FrontServeRun. It aborts everyLogical::AcceptedwithClosed, including on the orphanedInFlightearly-return path. Readers see the same thing as before apart from the error code: abort and an unfinished drop both tear down open groups, andDroppedandClosedare bothtransient().- Quest bookkeeping. The claimed quest file is removed and the new m3 quest
flv-export-arrivalis added.
claude-opus-5-5 | 𝕏
|
Maintainer decision (2026-11-17, asked in the ✅ Keep the follow-up (Written by Claude Opus 5.5 with high) |
A video track whose timeline should step waits for its next keyframe, which a sender that keys only on request never sends. Ask with PLI, once an interval, where it was negotiated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
✅ No new issues found. The new commit fixes the prior finding about a deferred video step that had no deadline.
Reviewed changes
Changes since bfc3770: the deferred step now asks for a keyframe, and the quest file notes that the maintainer kept it.
Mapped::deferred.IngestClock::normalizenow reports when it holds a step on a delta frame. The session loop then sends a PLI through the newrequest_keyframehelper, whichAdmit::Requestnow shares.- Rate-limited requests.
IngestLine::Videonow has arequest_atfield that it takes over fromKeyless, so a line can ask at most once perKEYFRAME_REQUEST_INTERVAL(1 s). A line without PLI and an audio line never ask.a_deferred_step_asks_for_a_keyframetests both cases. - Quest note.
quest/m3/flv-export-arrival.mdnow records the maintainer's decision to keep the quest.
claude-opus-5-5 | 𝕏

Claims quest/m2/whep-chain-shutdown.md, the follow-up of moq-dev/moq#8997.
Summary
Stopping
moq import webrtc --connect <whep> -- export rtmp --connect <rtmp>with SIGTERM exits 0, with notrack::Producer dropped without finish() or abort()and no clock-drift error.The drift error was not the stop's. In the loopback chain it fires about 6 s into a run on its own, 3 of 14 runs on
main, and a stop merely lands on a process that already died of it. The ingest starts each track's timeline on arrival time, then moves to the sender's RTCP reports once every track has one (about 5 s in). The two tracks' arrival skew was up to 470 ms, so the track placed earlier (audio) stepped forward by that much, with nothing telling a reader. The export's jitter buffer reads an unmarked step under half the delay as a move in latency, and one that is not as the source's clock running 60000 ppm fast. Now:IngestClock::normalizetakes the step only on a frame that opens a group (every audio frame, a video keyframe), keeping a video track's timeline through the deltas of its group, and says so.Bridge::discontinuity, one line per codec).The unfinished tracks had two sources, both a cancelled future that drops what it holds:
IngestSinkdropped with its bridges and catalog open (Session::runaborts only when its loop returns). It now aborts them withCancelon drop; finished or aborted sinks have nothing left to abort.track::Producerof the same names, 2 to 4 warnings a stop), thoughDriver's docs say dropping it aborts active fronts. A droppedFrontServeRunnow ends them withClosed.Validation
import fmp4 -- export webrtc --listenas the WHEP source, the chain, and animport rtmp --listen -- export rtmp --listensink), the chain stopped with SIGTERM after 5 to 9 s:+91814,+252,+286 ppm).catalog::intervaloverruns (21 of 30, also on the base) andFLV export only supports one audio track(4 of 30, seen before the marker change; not investigated).decode - arrivaljumped 0.33 s at the sender reports. A second failing run was audio only, which is why a buffer-side loosening (judging drift only after the rate could have cost half the delay) was dropped: it cannot tell one track's 0.3 s step from drift, and a publisher's unmarked step is the publisher's to mark.session::tests::the_sender_reports_step_a_track_where_a_group_opensandvideo_takes_a_step_at_its_next_keyframe(the exact stepped timestamps, who takes the step and when),ingest::tests::a_step_publishes_a_marker_group(4 groups: two frames, the marker, the next),a_deferred_step_asks_for_a_keyframe(a PLI at once, then at most once a second, none without PLI),a_dropped_sink_aborts_its_tracks(Cancel, notDropped), andorigin::tests::teardown_ends_the_logical_tracks, which warned before theDrop.just checkpasses (11823 tests).just test interop --all: all checks passed.Public API and wire impact
None to the public API:
MediaSinkandBridgeare crate-private, andmoq-netgains aDroponly. On the wire an ingest now publishes a discontinuity marker group where a step happens, once per session about 5 s in, which is the existing marker every reader handles.Decisions
quest/m3/flv-export-arrival.md(rejected: drop it). The maintainer's answer, on this PR.KEYFRAME_REQUEST_INTERVALlike the first-keyframe request (rejected: let the step land unmarked after a cap, which brings back the unmarked step this PR removes; rejected: wait for the sender's own keyframes, since browser encoders key only on request). Judged on Pullfrog's finding: real, since libwebrtc sends no periodic keyframes.Caused by
Follow-ups
FlvTrack::empty, not the frame's real arrival, is whatExport::fillhands the jitter buffer, so a track whose reads the buffer gates looks sent further ahead each frame. No open decisions. Kept by the maintainer (comment); recorded in its Plan.Models
Size: S
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (arm B)
Implementer: Claude Code, claude-sonnet-5-5, unknown effort (iterate, S, arm B)
(Written by Claude Sonnet 5.5)
Review
Rewritten by
quest reviewafter each round.Head: 0e15f1d
Base: origin/main at f88e8f5
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:
01a1eb61-6bf0-7260-8b09-abd0983262bb, round 3Score: 10/10,
Source review found no new issues in the incremental change, which requests rate-limited keyframes when a video timeline step is deferred; builds and tests were not run.Rounds: 3; first round 1 (medium 1); findings 1 (medium 1): fixed 1, refuted 0, open 0
Findings: none