From d7731b5ee2e095c2da25d455a560bdbafd1a75b6 Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:09:29 +0000 Subject: [PATCH 1/2] test(verify): keep crash-harness frames on the capture grid when the timer wakes late --- crates/verify/tests/crash.rs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/crates/verify/tests/crash.rs b/crates/verify/tests/crash.rs index 68e53407323..8b40a10fcf3 100644 --- a/crates/verify/tests/crash.rs +++ b/crates/verify/tests/crash.rs @@ -92,6 +92,10 @@ const SECONDS: f64 = 8.0; /// container round to at most 1/90000 s; half a millisecond is far below the /// 33 ms frame period and above any rounding. const PTS_TOLERANCE: f64 = 0.0005; +/// Well under the 50 ms after which the pipeline stops trusting the capture +/// time of the first frame after a quiet source. +const MAX_HAND_OFF_LATENESS: Duration = Duration::from_millis(10); +const MAX_LATE_WAKES: u32 = 20; const CHILD_ENV: &str = "CAP_VERIFY_CRASH_CHILD"; #[derive(Clone, Copy, Debug, PartialEq, Eq)] @@ -424,15 +428,31 @@ async fn record( let mut health = pipeline.take_health_rx(); let base = Instant::now() + Duration::from_millis(50); let mut handed = Vec::new(); + let period = 1.0 / f64::from(FPS); + let mut previous_slot: Option = None; for index in slots { - let at = base + Duration::from_secs_f64(f64::from(index) / f64::from(FPS)); - tokio::time::sleep_until(at.into()).await; + // A capture is handed over as it happens. When the timer wakes late + // (a loaded runner), the frame moves to the next slot of the nominal + // grid instead of carrying a capture time older than its hand-off: + // after a static gap the pipeline restamps such a frame on purpose. + let mut slot = previous_slot.map_or(index, |previous| index.max(previous + 1)); + let mut at = base + Duration::from_secs_f64(f64::from(slot) * period); + for wake in 1.. { + tokio::time::sleep_until(at.into()).await; + let late = Instant::now().saturating_duration_since(at); + if late <= MAX_HAND_OFF_LATENESS || wake == MAX_LATE_WAKES { + break; + } + slot += (late.as_secs_f64() / period).ceil() as u32; + at = base + Duration::from_secs_f64(f64::from(slot) * period); + } + previous_slot = Some(slot); let picture = pictures.next().expect("rendered"); let frame = source::frame(picture, at); tx.send_async(frame) .await .map_err(|_| anyhow!("pipeline stopped taking frames at {index}"))?; - let secs = f64::from(index) / f64::from(FPS); + let secs = f64::from(slot) * period; handed.push(Handed { index, secs }); log.line(&format!("f {index} {secs:.6}")); if let Some(hook) = live.on_frame.as_mut() { From 01b03f5f26b6e6a76a8f1cfc0de1f449e8abbb76 Mon Sep 17 00:00:00 2001 From: Richie McIlroy <33632126+richiemcilroy@users.noreply.github.com> Date: Thu, 19 Nov 2026 01:32:16 +0000 Subject: [PATCH 2/2] test(verify): re-slot only static-screen frames, past Windows timer granularity --- crates/verify/tests/crash.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/crates/verify/tests/crash.rs b/crates/verify/tests/crash.rs index 8b40a10fcf3..1a78a03e08a 100644 --- a/crates/verify/tests/crash.rs +++ b/crates/verify/tests/crash.rs @@ -92,9 +92,10 @@ const SECONDS: f64 = 8.0; /// container round to at most 1/90000 s; half a millisecond is far below the /// 33 ms frame period and above any rounding. const PTS_TOLERANCE: f64 = 0.0005; -/// Well under the 50 ms after which the pipeline stops trusting the capture -/// time of the first frame after a quiet source. -const MAX_HAND_OFF_LATENESS: Duration = Duration::from_millis(10); +/// Under the 50 ms after which the pipeline stops trusting the capture time +/// of the first frame after a quiet source, and above Windows' 15.6 ms timer +/// granularity. +const MAX_HAND_OFF_LATENESS: Duration = Duration::from_millis(25); const MAX_LATE_WAKES: u32 = 20; const CHILD_ENV: &str = "CAP_VERIFY_CRASH_CHILD"; @@ -431,16 +432,17 @@ async fn record( let period = 1.0 / f64::from(FPS); let mut previous_slot: Option = None; for index in slots { - // A capture is handed over as it happens. When the timer wakes late - // (a loaded runner), the frame moves to the next slot of the nominal - // grid instead of carrying a capture time older than its hand-off: - // after a static gap the pipeline restamps such a frame on purpose. + // On a mostly static screen every frame follows a quiet gap, and the + // pipeline restamps such a frame from its hand-off on purpose when its + // capture time is much older. So when the timer wakes late (a loaded + // runner) the frame moves to a later slot of the nominal grid instead. + // A steady stream keeps its capture times however late it is handed. let mut slot = previous_slot.map_or(index, |previous| index.max(previous + 1)); let mut at = base + Duration::from_secs_f64(f64::from(slot) * period); for wake in 1.. { tokio::time::sleep_until(at.into()).await; let late = Instant::now().saturating_duration_since(at); - if late <= MAX_HAND_OFF_LATENESS || wake == MAX_LATE_WAKES { + if step <= 1 || late <= MAX_HAND_OFF_LATENESS || wake == MAX_LATE_WAKES { break; } slot += (late.as_secs_f64() / period).ceil() as u32;