From 814646e5827e40f4ec11a57d1dc185c7bf2b8eb9 Mon Sep 17 00:00:00 2001 From: Evan Brown <153393779+etgbrown@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:21:39 -0600 Subject: [PATCH] fix(streamer): leave room for a repaired gap's frames in the media queues When a retransmission fills a gap, the reorder queue releases every frame it held behind it in one burst: 7-9 frames for the 52 ms wait at 120 fps. The transport hands frames to the core through an 8-slot channel with try_send, so the ninth was dropped, a keyframe was requested, and the frames already queued were discarded with the broken chain. A loss that the retransmission had repaired still cost a keyframe wait. In a 3-minute 3840x2160@120 AV1 session over Starlink with small frames, this happened 6 times, 67-97 ms after a packet-loss burst, each discarding 3-14 frames and waiting 27-75 ms for the keyframe. Raise the channel to 32 frames and the Linux decoder's encoded queue from 16 to 32, comfortably above a 52 ms release at 240 fps. Both stay bounded. After the change, no such drop in four 3-minute sessions. Co-Authored-By: Claude Fable 5.2 Co-Authored-By: Claude Opus 5.5 --- .../crates/opennow-streamer-core/src/lib.rs | 6 +++++- .../crates/opennow-streamer-platform-linux/src/session.rs | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/native/opennow-streamer/crates/opennow-streamer-core/src/lib.rs b/native/opennow-streamer/crates/opennow-streamer-core/src/lib.rs index 446322e6a..36a131546 100644 --- a/native/opennow-streamer/crates/opennow-streamer-core/src/lib.rs +++ b/native/opennow-streamer/crates/opennow-streamer-core/src/lib.rs @@ -128,7 +128,11 @@ enum State { Connected, } -const ENCODED_MEDIA_QUEUE_CAPACITY: usize = 8; +/// When a lost packet is retransmitted, the reorder queue releases every frame it held behind +/// the gap at once: up to 52 ms of video, 7 frames at 120 fps or 13 at 240, and more when +/// several waits overlap. A frame that does not fit is dropped and costs a keyframe, so leave +/// room for such a release. +const ENCODED_MEDIA_QUEUE_CAPACITY: usize = 32; const NVST_RECOVERY_ATTEMPT_LIMIT: usize = 1; const NATIVE_INPUT_POLL_INTERVAL: Duration = Duration::from_micros(250); const MAX_STREAM_FPS: u32 = 360; diff --git a/native/opennow-streamer/crates/opennow-streamer-platform-linux/src/session.rs b/native/opennow-streamer/crates/opennow-streamer-platform-linux/src/session.rs index 6529b9153..9617a3da3 100644 --- a/native/opennow-streamer/crates/opennow-streamer-platform-linux/src/session.rs +++ b/native/opennow-streamer/crates/opennow-streamer-platform-linux/src/session.rs @@ -103,8 +103,9 @@ impl SessionConfig { // retires a large frame or reallocates surfaces. Four frames is // too small for a 120 Hz stream and turns a harmless burst into a // decoder reset. Keep this bounded, but absorb roughly two frame - // batches before initiating keyframe recovery. - encoded_queue_depth: 16, + // batches before initiating keyframe recovery. A repaired network gap + // releases every frame held behind it at once (13 at 240 fps). + encoded_queue_depth: 32, decoded_queue_depth: 3, audio: Some(AudioConfig::default()), }