fix(neshub): a picture switch waits for the new keyframe even behind a stalled writer (#425)

Follow-up to #423 from its re-review. The dgram writer now raises
awaiting_keyframe when it reaches the Resubscribe marker, in queue
order, and restart_picture sets the flag before queuing the marker.
Before this, an old keyframe still queued ahead of a primary switch
could clear the flag, letting the new picture's first delta out as the
first frame an old client saw after the switch. Needs a writer stalled
for at least 1 s to trigger.

Tested: cargo test -p neshub on nestripc-1, 78 passed.
This commit is contained in:
Wanjohi
2026-10-17 16:47:36 +03:00
committed by GitHub
parent 4a0a790fd1
commit 0c348d3973
2 changed files with 8 additions and 1 deletions
+7
View File
@@ -318,6 +318,13 @@ pub async fn run_datagram_writer(
MediaItem::Resubscribe => {
seq = 0;
resync = ResyncGate::default();
// Set here, in queue order, not only by whoever queued this: a
// keyframe from the old picture still queued ahead of it would
// otherwise clear the flag, and the new picture's first delta
// would go out as the first frame after the switch.
if let Some(ref awaiting) = awaiting_keyframe {
awaiting.store(true, Ordering::Relaxed);
}
continue;
}
// No keyframe stream and no resync gate: every PyroWave frame
+1 -1
View File
@@ -513,10 +513,10 @@ impl ClientSession {
/// zero, hold deltas until a keyframe, and forget what it reported about
/// the old one. The caller asks for the keyframe.
pub fn restart_picture(&self) {
self.awaiting_keyframe.store(true, Ordering::Relaxed);
if self.pending_video.is_none() {
let _ = self.send_video.send(MediaItem::Resubscribe);
}
self.awaiting_keyframe.store(true, Ordering::Relaxed);
let _ = self.take_report();
}