fix(sync): drop startup-stale video until fresh

This commit is contained in:
Brad Stein 2026-04-26 15:37:57 -03:00
parent 65e6f84f8d
commit 3bf53922bd
5 changed files with 47 additions and 17 deletions

View File

@ -4,7 +4,7 @@ path = "src/main.rs"
[package]
name = "lesavka_client"
version = "0.14.4"
version = "0.14.5"
edition = "2024"
[dependencies]

View File

@ -1,6 +1,6 @@
[package]
name = "lesavka_common"
version = "0.14.4"
version = "0.14.5"
edition = "2024"
build = "build.rs"

View File

@ -10,7 +10,7 @@ bench = false
[package]
name = "lesavka_server"
version = "0.14.4"
version = "0.14.5"
edition = "2024"
autobins = false

View File

@ -279,6 +279,7 @@ impl Relay for Handler {
let mut pending = std::collections::VecDeque::new();
let mut inbound_closed = false;
let stale_drop_budget = upstream_stale_drop_budget();
let mut startup_video_settled = false;
loop {
if !camera_rt.is_active(session_id)
|| !upstream_media_rt.is_camera_active(upstream_lease.generation)
@ -338,13 +339,26 @@ impl Relay for Handler {
continue;
}
if plan.late_by > stale_drop_budget {
tracing::warn!(
rpc_id,
session_id,
late_by_ms = plan.late_by.as_millis(),
pts = plan.local_pts_us,
"🎥 upstream video frame dropped after missing its freshness budget"
);
let coalesced = retain_freshest_video_packet(&mut pending);
if startup_video_settled {
tracing::warn!(
rpc_id,
session_id,
late_by_ms = plan.late_by.as_millis(),
pts = plan.local_pts_us,
dropped_pending = coalesced,
"🎥 upstream video frame dropped after missing its freshness budget"
);
} else {
tracing::debug!(
rpc_id,
session_id,
late_by_ms = plan.late_by.as_millis(),
pts = plan.local_pts_us,
dropped_pending = coalesced,
"🎥 dropping startup-stale upstream video until the playout window settles"
);
}
continue;
}
tokio::time::sleep_until(plan.due_at).await;
@ -352,16 +366,30 @@ impl Relay for Handler {
.checked_duration_since(plan.due_at)
.unwrap_or_default();
if actual_late_by > stale_drop_budget {
tracing::warn!(
rpc_id,
session_id,
late_by_ms = actual_late_by.as_millis(),
pts = plan.local_pts_us,
"🎥 upstream video frame dropped after waking too late for fresh playout"
);
let coalesced = retain_freshest_video_packet(&mut pending);
if startup_video_settled {
tracing::warn!(
rpc_id,
session_id,
late_by_ms = actual_late_by.as_millis(),
pts = plan.local_pts_us,
dropped_pending = coalesced,
"🎥 upstream video frame dropped after waking too late for fresh playout"
);
} else {
tracing::debug!(
rpc_id,
session_id,
late_by_ms = actual_late_by.as_millis(),
pts = plan.local_pts_us,
dropped_pending = coalesced,
"🎥 dropping startup-stale upstream video after a late wake until the playout window settles"
);
}
continue;
}
pkt.pts = plan.local_pts_us;
startup_video_settled = true;
relay.feed(pkt); // ← all logging inside video.rs
}
upstream_media_rt.close_camera(upstream_lease.generation);

View File

@ -219,6 +219,7 @@ impl Relay for Handler {
continue;
}
if plan.late_by > stale_drop_budget {
let _ = retain_freshest_video_packet(&mut pending);
continue;
}
tokio::time::sleep_until(plan.due_at).await;
@ -226,6 +227,7 @@ impl Relay for Handler {
.checked_duration_since(plan.due_at)
.unwrap_or_default();
if actual_late_by > stale_drop_budget {
let _ = retain_freshest_video_packet(&mut pending);
continue;
}
pkt.pts = plan.local_pts_us;