Fix silent frame-chain corruption on EnqueueFrame rejection; revert to 720p
Root cause (found by Opus 5 second-opinion review) of the freezing that survived every prior fix tonight: openscreen's Sender caps in-flight unacknowledged media at clamp(2*RTT, 66ms, 133ms) -- on a LAN that's pinned at the 66ms floor, about two frames at 30fps. When EnqueueFrame rejects a frame under that budget, facade.cc discarded the result (`(void)video_sender->EnqueueFrame(frame)`) and moved on. But vah264enc had already encoded the *next* frame as a P-slice depending on the one that just got silently dropped -- the encoder has no idea the drop happened, since it happens downstream of encoding, at this FFI boundary. The receiver sees an unbroken frame-ID sequence (nothing here told it otherwise) and decodes a P-slice against a reference picture it never received: a stuck/corrupted frame until the next regularly-scheduled key frame (up to ~2s, longer if that key frame is itself dropped the same way -- explains the 20+s outlier). Zero "receiver reported picture loss" lines across 195s of a visibly freezing session confirms the receiver genuinely never noticed anything was wrong, which a real decode-capability or packet-loss problem would have triggered. This also explains why moving to a faster network made it *worse*: the in-flight budget is RTT-derived, not bandwidth-derived, so more throughput doesn't raise the 66ms floor at all -- while 1080p tripled the per-frame packet count, increasing how often frames missed that window. Fixed the actual corruption: both drop paths in facade.cc (the EnqueueFrame rejection, and the pre-existing non-monotonic-capture-time guard) now set a `frame_chain_broken` flag, consumed once by breadcast_caststream_sender_needs_key_frame() so frame_pump_loop forces a key frame on the very next frame instead of chaining more P-slices onto a reference that no longer exists on the receiver. A separate flag from the existing `needs_key_frame` atomic because SchedulePoll's 100ms timer unconditionally overwrites that one with the Sender's own (unrelated) NeedsKeyFrame() reading, which would have silently clobbered this signal. Also reverted the Cast Streaming pipeline from tonight's 1080p experiment back to 1280x720 (build_video_pipeline_for_streaming + VideoParams::default(), which must agree -- a mismatch there is a separate protocol-level bug fixed earlier tonight). Not the root cause, but a real contributing factor per the packet-count reasoning above, and untangling it from the frame_chain_broken fix by changing both at once would make the next test ambiguous. Kept the 6000/1500 kbps bitrate range from earlier tonight, now actually paired with 720p for the first time. The deeper real fix -- raising openscreen's 66ms in-flight floor itself, which trades latency for headroom -- is out of scope for tonight; this targets the corruption mechanism (via the sanctioned, if awkward, needs_key_frame signal) without touching vendored openscreen constants.
This commit is contained in:
parent
a058482b39
commit
22a18eee1b
4 changed files with 55 additions and 26 deletions
|
|
@ -55,12 +55,14 @@ impl Default for VideoParams {
|
|||
// a resolution other than what's actually sent is a real
|
||||
// protocol mismatch that plausibly explains a receiver decoder
|
||||
// corrupting/freezing rather than just looking soft.
|
||||
width: 1920,
|
||||
height: 1080,
|
||||
// Reverted from a brief 1920x1080 experiment -- see
|
||||
// `build_video_pipeline_for_streaming`'s doc comment for why
|
||||
// (the freeze wasn't a resolution/bandwidth problem at all).
|
||||
width: 1280,
|
||||
height: 720,
|
||||
// Kept equal to `breadcastd::cast_mirror::MAX_BITRATE_KBPS *
|
||||
// 1000` -- see that constant's doc comment for why 8 Mbps
|
||||
// (this struct's previous value) isn't used here even though
|
||||
// 1080p can look better with more headroom: real hardware
|
||||
// (this struct's previous value) isn't used here: real hardware
|
||||
// testing showed the AIMD probe pinning to whatever this
|
||||
// ceiling is for the entire session once the estimator reports
|
||||
// (unreliably) that there's room, and 8 Mbps sustained was more
|
||||
|
|
|
|||
|
|
@ -150,19 +150,20 @@ pub fn build_video_pipeline_for_streaming(
|
|||
) -> Result<(gst::Pipeline, gst_app::AppSink, gst::Element)> {
|
||||
gst::init().context("failed to initialize GStreamer")?;
|
||||
|
||||
// 1920x1080@30 Main profile -- raised from the earlier 1280x720
|
||||
// baseline (kept in `build_video_pipeline`'s HLS path, which targets a
|
||||
// different, less capable receiver -- see its doc comment) once real
|
||||
// hardware testing showed the actual bottleneck on the *previous*
|
||||
// network wasn't resolution but the encoder being driven well past
|
||||
// what that link/receiver could sustain (see `MAX_BITRATE_KBPS` in
|
||||
// `breadcastd::cast_mirror`). Must stay equal to `VideoParams::default`
|
||||
// in `caststream.rs` -- the OFFER's advertised resolution and what's
|
||||
// actually encoded disagreeing is a protocol-level mismatch, not just
|
||||
// soft video (see that struct's doc comment for what that caused).
|
||||
// 1280x720@30 Main profile. Briefly raised to 1080p, then reverted here:
|
||||
// a near-instant freeze *on a faster network* turned out to have nothing
|
||||
// to do with resolution or bandwidth at all -- see `frame_chain_broken`
|
||||
// in `breadcast-caststream-sys/src/facade.cc` for the actual bug (the
|
||||
// FFI silently drops frames under openscreen's in-flight budget and lets
|
||||
// the encoder's reference chain corrupt as a result). 1080p roughly
|
||||
// tripled the per-frame packet count, which made that bug's real trigger
|
||||
// -- exceeding the in-flight window -- worse, not the resolution itself.
|
||||
// Reverted alongside fixing that bug rather than keeping both variables
|
||||
// in motion at once; revisit once `frame_chain_broken` on its own is
|
||||
// confirmed to have fixed the freeze at 720p.
|
||||
let pipeline_str = "pipewiresrc path=%VIDEO_NODE_ID% do-timestamp=true ! \
|
||||
videoconvert ! videoscale ! videorate ! \
|
||||
video/x-raw,format=NV12,width=1920,height=1080,framerate=30/1 ! \
|
||||
video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! \
|
||||
vah264enc name=venc bitrate=4000 key-int-max=60 rate-control=cbr ! \
|
||||
video/x-h264,profile=main ! \
|
||||
h264parse name=h264parse config-interval=-1 ! \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue