From c4705cbb2cf82975f5f6b7ff1c3472a7c8af5a6c Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Sat, 22 Aug 2026 19:40:18 +0800 Subject: [PATCH] test: playback tracking asserts on playhead progress, not wall time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit playback_display_tracks_the_playhead used a 30 s wall-clock deadline as its pass/fail criterion, so a slow or loaded machine failed the test for machine speed, not for a broken pipeline — spurious, unrelated to any race. The loop now terminates on playback-clock progress (playhead >= 120, ~5 s of playback; the transport advances independently of render speed, so termination is guaranteed) and the only judgment is the tracking invariant at that point. No Instant::now() remains. Verified green on a heavily loaded machine in 84 s. --- crates/oak-app/src/oakui/real.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/crates/oak-app/src/oakui/real.rs b/crates/oak-app/src/oakui/real.rs index b20e9b8a9..43d0e7fe0 100644 --- a/crates/oak-app/src/oakui/real.rs +++ b/crates/oak-app/src/oakui/real.rs @@ -6925,7 +6925,15 @@ mod tests { }); cx.update(|app| engine.update(app, |engine, cx| engine.play(Monitor::Program, cx))); - let deadline = std::time::Instant::now() + Duration::from_secs(30); + // Track-the-playhead smoke test. The loop's progress criterion is + // the playback clock itself, NOT wall time: the transport advances + // independently of render speed, so the loop always terminates + // after ~5 s of playback regardless of how fast the machine is. + // The assertion is the only judgment: once playback has progressed, + // the displayed frame must have tracked the playhead. A wall-clock + // deadline here would fail the test for machine slowness rather + // than for a broken pipeline — exactly the spurious failures we + // are avoiding. let mut last_displayed = -1i64; loop { cx.update(|app| engine.update(app, |engine, cx| engine.tick(cx))); @@ -6949,13 +6957,15 @@ mod tests { (playhead, displayed, slots) }); last_displayed = last_displayed.max(displayed); - if displayed >= 3 && playhead - displayed < 4 { + // 120 frames ≈ 5 s at 24 fps: enough for the pre-render window + // to warm up on any machine. The playhead always gets here. + if playhead >= 120 { + assert!( + displayed >= 3 && playhead - displayed < 4, + "the displayed frame must track the playhead (playhead {playhead}, displayed {displayed}, peak displayed {last_displayed}, window slots {slots})" + ); break; } - assert!( - std::time::Instant::now() < deadline, - "the displayed frame must track the playhead (playhead {playhead}, displayed {displayed}, peak displayed {last_displayed}, window slots {slots})" - ); // The viewer paints at ~60 Hz. std::thread::sleep(Duration::from_millis(16)); cx.update(|app| {