Repository navigation
fix(mpegtssrt_input): keep an absent SRT peer from holding the flow - #812
Conversation
8508006 to
bd98a3d
Compare
srperens
left a comment
There was a problem hiding this comment.
Verdict: Approve — correct mechanism, confined radius, and both new tests provably executed against a real srtsrc rather than skipping green. The teardown question this pattern usually raises settles clean, for a reason worth recording below.
Claims
| Claim | Verdict | Evidence |
|---|---|---|
| Both new tests executed on CI rather than skipping | CONFIRMED |
job 103857768870: test absent_srt_caller_does_not_block_playing ... ok, test late_srt_caller_is_decoded ... ok. The skip guard cannot fire quietly — backend/tests/mpegtssrt_absent_caller_test.rs:23 — "srtsrc", is in the required list and .github/workflows/ci.yml:149 — STROM_REQUIRE_GST_PLUGINS: 1 turns a missing element into a failure, so a green pass proves srtsrc was present |
| The probe takes no strong reference to a pipeline object | CONFIRMED |
backend/src/blocks/builtin/mpegtssrt_input.rs:518 — let decodebin_weak = decodebin.downgrade();, and it detaches at mpegtssrt_input.rs:541 — gst::PadProbeReturn::Remove |
| A decodebin left locked forever (no peer ever connects) still tears down cleanly | CONFIRMED |
mpegtssrt_input.rs:257 — prepare_idle_decodebin(&element); runs at build time, before the element joins the pipeline, so an unactivated decodebin never leaves NULL. backend/src/gst/pipeline/lifecycle.rs:220 sets only the pipeline to NULL and would not reach a locked child — which is exactly why locking before the first transition, rather than after, is what makes this safe |
| AES67 Input has the same defect and is not fixed here | CONFIRMED |
backend/src/blocks/builtin/aes67.rs:371 — let decodebin = gst::ElementFactory::make("decodebin") is built with neither set_locked_state nor async-handling |
Diagnosis — The stated cause explains the whole symptom: a child stuck ASYNC holds the bin's transition, so one peerless SRT input freezes every other block in the flow. Unlocking on the second downstream event is the right trigger, because srtsrc emits STREAM_START at task start whether or not a peer exists. Worth noting for the design record: async-handling=true alone would already prevent the stall, since an unlocked decodebin then absorbs its own ASYNC. The probe is what keeps the decodebin out of the pipeline until data actually arrives, so the two parts are not redundant — they answer the stall and the state-loss symptom respectively, which matches the body's account.
Coverage is BOUNDED and the bound is disclosed rather than missed: AES67 Input has the same shape and needs a different trigger (its decodebin is fed from rtpbin pad-added). That belongs in its own issue, not in this diff.
Radius — LOCAL. One block, decode mode only; decode=false builds tsdemux, which does not return ASYNC, and is untouched.
Tests & CI — Check (Linux), Build (Linux x86_64/ARM64), Check & Build (WASM), API Contract Check green at bd98a3d. The PR body says "CI has not run yet"; it has since, on this head. macOS and Windows report skipping, which is right here — no platform-specific code.
One limit on that evidence, stated so it is not mistaken for more than it is: pipeline_lifecycle_test is the canary CLAUDE.md names for new closures, and it does not reach this block — backend/tests/pipeline_lifecycle_test.rs:23 — element_type: "audiotestsrc".to_string(), is the whole flow it builds. Its passing says nothing about this probe. The WeakRef above was confirmed by reading, not by that test.
Nothing was run locally — this runner has no cargo and no GStreamer. Every statement is read off the job log or the source.
Confidence: HIGH
In decode mode the block builds srtsrc -> decodebin at flow start. A decodebin cannot complete READY->PAUSED until it has data to typefind, so a listener with no caller (or a caller whose listener is not up) holds the whole pipeline in PAUSED, stopping the mixer, WHEP outputs and every other input until the SRT peer connects. The decodebin now starts with its state locked and async-handling set. An EVENT_DOWNSTREAM probe on srtsrc's src pad unlocks it on the first event after the startup STREAM_START. srtsrc sends nothing past STREAM_START until it has read data, so the decodebin is running before the first buffer. async-handling keeps its preroll inside a running pipeline from making the pipeline lose state. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
bd98a3d to
a136f9a
Compare
|
Claude (AI), on behalf of @wagenet. Rebased onto upstream/main (now a136f9a). Ran (macOS, |
srperens
left a comment
There was a problem hiding this comment.
Verdict: Approve — supersedes my review of 2026-09-14 (Approve at bd98a3d, auto-dismissed by the push); the verdict stands. The new head a136f9a is a rebase: the block diff is unchanged apart from the restored AtomicBool import, and the test's local skip helper became the shared common::plugins_available(REQUIRED) from #912. The other rows carry over from that review.
Claims
| Claim | Verdict | Evidence |
|---|---|---|
| The rebase changed nothing in the mechanism | CONFIRMED |
^[-+] diff of both heads over the two files: only the import and the skip helper differ |
| Both tests executed in CI at this head | CONFIRMED |
Check (Linux) job 110914547462: absent_srt_caller_does_not_block_playing ... ok, late_srt_caller_is_decoded ... ok |
| A missing element still fails rather than skips | CONFIRMED |
backend/tests/common/mod.rs:42 — pub fn plugins_available(required: &[&str]) -> bool { and .github/workflows/ci.yml:146 — STROM_REQUIRE_GST_PLUGINS: 1 |
| Probe holds no strong ref and removes itself | CONFIRMED |
backend/src/blocks/builtin/mpegtssrt_input.rs:611 — let decodebin_weak = decodebin.downgrade();, backend/src/blocks/builtin/mpegtssrt_input.rs:634 — gst::PadProbeReturn::Remove |
Diagnosis — Unchanged from my earlier review. Coverage is BOUNDED to decode mode of this block. AES67 Input has the same shape and is still unfixed on main: backend/src/blocks/builtin/aes67.rs:371 — let decodebin = gst::ElementFactory::make("decodebin"). The lock pattern is now an established one in the tree. WHIP Input does the same at backend/src/blocks/builtin/whip.rs:255 — decodebin.set_locked_state(true);, so this PR adds no new idiom.
SPECULATIVE (not verified): if SRT data first arrives while stop() has the pipeline mid-NULL, the probe unlocks and syncs a decodebin that the bin skipped as locked. The window is one event, and WHIP slots share it. I am not asking for a change.
Radius — LOCAL. One block, decode mode only.
Overlaps — #813 changes the same file (tsdemux_anchor inside the same decodebin). Merging this PR onto origin/main and then #813 on top is clean, and the two hook into different points (a probe on srtsrc's src pad here, tsdemux setup inside the decodebin there). So the order does not matter. #968 (unclean caller death) is srtsrc behaviour and not touched here.
Tests & CI — The CI run is from 2026-10-02 at merge base ca85fab. Main is 69 commits ahead, but none of them touches mpegtssrt_input.rs, tests/common/mod.rs or BlockBuildContext::new, and a local trial merge onto main is clean. I did not build that merge locally (no cargo or GStreamer on this runner). macOS and Windows skipping, which is fine: the PR has no platform code.
Confidence: HIGH
Opened by Claude (AI) on behalf of @wagenet.
The stall
In decode mode (the default) the MPEG-TS/SRT Input block builds
srtsrc -> decodebinat flow start. Adecodebincannot complete READY->PAUSED until it has data to typefind, and a pipeline with any child still ASYNC never completes its own transition. An SRT listener whose caller has not connected, or a caller whose listener is not up, delivers no data, so the whole flow sat inPauseduntil the SRT peer appeared: mixer, WHEP outputs and every other input stopped. Same class as #749 (idle WHIP slots) and #750 (unfed recorders).GST_DEBUG=GST_STATES:5on upstreammainwith no caller:The fix
The decodebin starts with its state locked and
async-handling=true, as in #749. What unlocks it is anEVENT_DOWNSTREAMprobe onsrtsrc's src pad.srtsrcpushes STREAM_START as soon as its streaming task starts, peer or not, and nothing else until it has read data. The probe lets that first STREAM_START through and unlocks and syncs the decodebin on the next event (the SEGMENT, or a retried STREAM_START), then removes itself. This runs on the streaming thread before the first buffer is pushed, so no buffer can reach a decodebin that is not running yet. Once active, the decodebin stays active across caller disconnects and reconnects.Without
async-handling, the decodebin's preroll inside the running pipeline makes the pipeline lose state: it postsPaused -> Paused, thenPaused -> Playing, so every sink in the flow briefly drops to PAUSED on each late connect.decode=falseis unchanged:tsdemuxdoes not return ASYNC.Verification
Release builds of
eae2467and this branch, a fresh headless backend per trial.mainPausedfor 12 sPlayingwhen start returnsPausedfor 15 sPlayingPlayingonly at connect (5.2 s); 233 frames, 1.29 MB audio decodedPlayingat 0.15 s; 233 frames, 1.29 MB audiomode=caller, listener comes up 4 s after startPauseduntil connectPlaying, decodesSRT audio delay on the program WHEP output (SRT latency 125 ms, caller connecting 1 s after start) is unchanged: 491–517 ms upstream, 500–511 ms here, 499–503 ms with the caller connecting 1 s after
Playing(3 trials each). Connect-to-first-frame matched within the 0.25 s polling resolution. The early-connect penalty (a caller that connects before flow start arrives ~1.24 s late) is the same on both builds.Tests
backend/tests/mpegtssrt_absent_caller_test.rsbuilds the block throughMpegTsSrtInputBuilderand wires its declared internal links, next to an independent liveaudiotestsrc -> audiomixer -> fakesinkbranch:absent_srt_caller_does_not_block_playing: no caller. The pipeline must reach PLAYING and the other branch must produce buffers.late_srt_caller_is_decoded: an in-processsrtsinkcaller connects after PLAYING. Its audio must be decoded, and the pipeline must post no state change while the decodebin prerolls.With the fix reverted, both fail (
decodebin: current Ready, pending Paused). With onlyasync-handlingremoved, the second fails on the lost-state messages. Every required element comes from a package CI already installs.Ran locally on macOS (GStreamer 1.28.6): the new tests (10 consecutive passes),
cargo test --workspace,cargo clippy --workspace --all-targets -- -D warningsandcargo fmt --all --check. CI has not run yet.Other network inputs checked
decodebinreturns ASYNC and the flow staysPaused. That decodebin is fed fromrtpbinpad-added, so it needs its own unlock trigger.efpdemuxhere) and NDI Input (no NDI runtime) were not tested.One early-connect trial on this branch hit
srtsrcnot-negotiatedright after the audio pad linked. The same error appears in an earlier upstreammainrig run, and it did not recur in 32 further trials across both builds.🤖 Generated with Claude Code