Repository navigation
feat(latency): name the inputs behind a mixer's latency failure - #1073
Conversation
srperens
left a comment
There was a problem hiding this comment.
Verdict: Comment. The diagnosis looks correct, and it runs only on warnings the #1072 gate lets through. I cannot approve because no check has run on this head: the PR targets fix/bridge-appsrc-latency, and CI only runs on pull requests into main (.github/workflows/ci.yml:7 — branches: [main]).
Requested changes
- Once #1072 merges, rebase onto
mainand retarget the base, so thatCheck (Linux)runslatency_diagnosis_testand the new unit tests.
Claims
| Claim | Verdict | Evidence |
|---|---|---|
| The diagnosis runs only for warnings the gate passes | CONFIRMED |
backend/src/gst/pipeline/bus.rs:146 — let warning_msg = match crate::gst::latency_diagnosis::diagnose_warning(. It sits after the early return at 140 |
| The pair is max(min) vs min(max) over live inputs | CONFIRMED |
describe takes the largest min against the smallest max; see Diagnosis |
This matches gst_aggregator_query_latency_unlocked, and min-upstream-latency raises both sides equally |
EXTERNAL |
Upstream GStreamer 1.26. Assumed as the body states |
| The new tests ran and guard the change | UNVERIFIED |
The author reports macOS runs and the reverts. No CI run exists for b73756b |
Diagnosis. It adds no new trigger. Pads that are non-live or unlinked drop out at backend/src/gst/latency_diagnosis.rs:34 — if !pad.peer_query(&mut query) {. The diagnosis appends text to a warning that already passed the gate. The origin walk is bounded by MAX_STEPS and stops at the first element with no linked sink pad or with several. The label falls back to the element id. block_names is a snapshot taken when the handler connects, so a block added to a running flow afterwards shows its id rather than its name. That is acceptable.
Cost: the queries run on the one GLib main loop that serves every flow's bus watch (backend/src/main.rs:1290 — let main_loop = glib::MainLoop::new(None, false);). A slow latency query would therefore delay bus handling for all flows. Latency queries are answered without the streaming lock in the elements used here, and GstBin itself issues them off the streaming threads: EXTERNAL. One more point: the gate's key includes the debug text, and that text carries the min and max values. If a jitterbuffer's reported min drifts (the test sees "2023 ms"), each new value is a new key, so the query can run more often than once per 10 s.
Radius. SHARED. Every flow's handler gains the code, but it acts only on an aggregator's "Impossible to configure latency" warning. Every other warning returns None before any query. The event shape is unchanged, so this is not a WebSocket contract change.
Overlaps. This PR is stacked on #1072 (it contains f989f53) and must land after it. No other open PR touches latency_diagnosis.rs or this branch of bus.rs.
Tests & CI. gh pr checks 1073 reports no checks. The integration test drives PipelineManager::start/stop and reads PipelineWarning, so it does exercise the wiring. The block-name label is untested, as the body says. Its elements come from plugins-good and plugins-base, both in the CI package list.
Confidence: HIGH
|
Since this PR was opened, main gained shared test setup in
let events = EventBroadcaster::with_capacity(4096);
let mut event_rx = events.subscribe();
let mut manager =
common::manager::build_with(&flow, events, std::env::temp_dir()).expect("build pipeline");
This does not block the PR: the code compiles and merges cleanly against main as it is. Please fold it in on your next rebase. Posted by Claude (AI) for the maintainers. |
f989f53 to
55b5ae2
Compare
b73756b to
96014e4
Compare
|
Rebased onto the updated #1072 (55b5ae2), which now masks digits in the gate key. That closes the point raised here: a drifting min ("2023 ms") no longer makes a new key, so the diagnosis query runs at most once per 10 s per aggregator. Verified the Ran locally on the rebased head: |
An aggregator that cannot configure its latency posts "Impossible to configure latency: max X < min Y" and names only itself. When the bus handler lets that warning through, it now asks each live input of the aggregator for its latency, walks each input upstream to its origin, and appends which input arrives latest and which one cannot be held back that long, by block name: GStreamer error: clock problem. 'SRT Input (V0)' arrives 2000 ms late, but 'WHIP Input (V15)' can only be held back 1000 ms. The query runs only for warnings the gate lets through, so at most once per 10 s per aggregator. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019c8J2sWW25auY4wAjxpoTN
96014e4 to
f4f30ee
Compare
srperens
left a comment
There was a problem hiding this comment.
Area: pipeline bus handling, explaining why a mixer cannot configure its latency
When the #1072 gate lets an aggregator's "Impossible to configure latency" warning through, this PR asks each live input for its latency and names the input that arrives latest and the one that can be held back least. The approach looks right and fits BLOCK_GUIDELINES "Reported Latency": it points at the input to fix, not at queue sizes. The diagnosis runs only after the gate (backend/src/gst/pipeline/bus.rs:153). The drifting-minimum point from the last review is fixed: the gate key masks digits (bus.rs:144). The closure captures only a map of block names, no GStreamer objects (bus.rs:70-80).
Neighbours: no other open PR touches bus.rs or latency_diagnosis.
- CI:
Check (Linux)is red, but not from this PR. The failure isvision_mixer_source_resize_test::source_switch_fits_when_caps_are_stored_late(GPU pipeline never reaches PLAYING), the flake tracked in #1092, which lists this run (39274515411). In the same run the 3 newlatency_diagnosisunit tests andlatency_diagnosis_testexecuted and passed. Re-run before merge. - Block names in the message are not exercised by any test (the body says so). A slip in
label(bus.rs:77-80) would pass CI while operators see raw ids (inline).
| let mut event_rx = events.subscribe(); | ||
| let registry_file = NamedTempFile::new().unwrap(); | ||
| let registry = BlockRegistry::new(registry_file.path()); | ||
| let mut manager = PipelineManager::new( |
There was a problem hiding this comment.
The maintainer's earlier request is still open: this builds PipelineManager by hand. common::manager::build_with(&flow, events, std::env::temp_dir()) covers it, and the BlockRegistry/NamedTempFile setup can go.
| .collect(); | ||
| // What the operator knows an element by: its block's name, or its own | ||
| // id for an element placed in the flow directly. | ||
| let label = move |element: &str| { |
There was a problem hiding this comment.
No test covers this block_id:element → block-name mapping. The integration test uses plain flow elements, so it only checks the fallback to the id. Moving this into a small fn in latency_diagnosis.rs would make it unit-testable.
…runners, and say why they fail (#1106) Both tests from #1073 fail now and then on the macOS and Windows runners: the mixer posts no "Impossible to configure latency" warning at all. In a diag run on the macOS runner the unit test failed 1 of 12 full lib-suite runs with CI's environment, and 0 of 25 runs on its own. They now skip there through skip_known_ci_failure and still run on Linux and locally. The real-pipeline test moves from the lib into latency_diagnosis_test so it can reach that helper. When either fails, its message now carries the pipeline state, the warnings the bus carried, and what each mixer input answers at the deadline. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Refs #1072. This PR uses the warning gate from #1072, which is merged; the branch is rebased onto main.
Problem
When a mixer's inputs disagree on latency, GStreamer posts:
It names only the aggregator, not which input is slow or which input cannot wait for it. On the production flow behind #1072 it took the debug graph, the flow JSON and local GStreamer experiments to find out that an SRT input at 2000 ms and a WHIP guest were the two sides. An operator has nothing to act on.
Change
When the bus handler lets an "Impossible to configure latency" warning from an aggregator through, it asks each live sink pad of that aggregator for its latency (a peer latency query, the same thing the aggregator does). It then appends the input that arrives latest and the input that can be held back the least, by block name:
gst_aggregator_query_latency_unlocked(1.26): the aggregator compares the largest minimum among its inputs against the smallest maximum.min-upstream-latencyraises both by the same amount, so it never causes the failure and is left out.block_id:elementare shown by their block's name; elements placed directly in the flow by their id.PipelineWarningevent shape is unchanged; only its text carries the diagnosis.Rejected: a new
StromEventvariant with structured min/max per input. That is a WebSocket contract change for what is, today, a message to read. It can come later if the UI wants to highlight the blocks.Evidence
a_mixer_latency_failure_is_reported_once_with_its_inputs(newbackend/tests/latency_diagnosis_test.rs) runs a flow throughPipelineManager. One input goes throughrtpjitterbuffer latency=2000, the other comes from a live appsrc at its defaults; both feed anaudiomixer. The test readsPipelineWarningevents for 3 s.bus.rsremoved, it fails:expected the latency warning once, got [].got ["GStreamer error: clock problem.: 'slow' arrives 2023 ms late, but 'bridge' can only be held back 1000 ms", "GStreamer error: ...(many).gst::latency_diagnosisunit tests:describepicks the right pair and says nothing when every input can wait.finds_both_inputs_of_a_mixer_that_cannot_configure_latencyrunsdiagnose_warningon a real failingaudiomixer.BlockInstance.idtoname.Tests
Ran on macOS (GStreamer 1.28.6):
cargo test --lib: 983 passed, 6 ignored.cargo test --test latency_diagnosis_test --test pipeline_lifecycle_test --test qos_probe_criticals_test: all passed.cargo clippy --all-targets: clean.Skipped: none. The test elements (
rtpL16pay,rtpjitterbuffer,rtpL16depay,audiomixer) are in gstreamer1.0-plugins-good/base, which are in the CI package list.Not run: on a server with a real SRT/WHIP flow.
For the reviewer
Out of scope
🤖 Generated with Claude Code
https://claude.ai/code/session_019c8J2sWW25auY4wAjxpoTN