From 397bd838c011494b62bacb3ea97aff0f28c2401b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Wed, 19 Aug 2026 21:16:52 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(app):=20a=20library=20previe?= =?UTF-8?q?w=20finally=20has=20a=20pulse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit render() ticked only the timeline's own session, never the preview one -- so a preview's audio-driven clock never advanced, pump() saw the same target every frame, and the picture sat frozen on frame 0 however long play ran. Ticks now go through active_session_mut(), the same preview-first routing pump/transport already use. --- crates/app/src/render.rs | 2 +- crates/app/src/tests/media.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/crates/app/src/render.rs b/crates/app/src/render.rs index bcda1d9..541c03b 100644 --- a/crates/app/src/render.rs +++ b/crates/app/src/render.rs @@ -8,7 +8,7 @@ impl Render for Player { // A file that has just been opened sits on its first frame with the // clock stopped: opening is not playing, whichever way the file // arrived. The play binding and the transport button start it. - if let Some(session) = &mut self.session { + if let Some(session) = self.active_session_mut() { session.tick(); } self.pump(window); diff --git a/crates/app/src/tests/media.rs b/crates/app/src/tests/media.rs index 4dfeed3..8680495 100644 --- a/crates/app/src/tests/media.rs +++ b/crates/app/src/tests/media.rs @@ -1279,6 +1279,30 @@ fn a_second_session_playing_never_moves_the_first() { ); } +/// The frozen-preview regression: `render` used to call `tick` on +/// `self.session` unconditionally, so a preview session's clock -- the one +/// [`Player::pump`] actually reads while previewing -- was never advanced +/// and the picture sat on frame 0 forever. The fix routes `tick` through +/// [`Player::active_session_mut`], the same preview-first precedence +/// `pump`/`transport` already use. This proves `tick` is what a session +/// needs to keep its own clock honest, and that ticking one session leaves +/// an untouched sibling exactly where it was -- so routing it through +/// whichever session is active cannot disturb the other one. +#[test] +fn ticking_the_preview_session_never_moves_the_timeline() { + let mut timeline = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); + timeline.seek(0.5); + let before = timeline.now(); + + let mut preview = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture"); + preview.play(); + // Stands in for what `render` now does every frame while a preview is + // showing: only the active session -- the preview -- gets ticked. + preview.tick(); + + assert_eq!(timeline.now(), before, "ticking the preview moved the timeline's clock"); +} + /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a /// synthetic 2x2 frame -- one pixel per corner, alpha and channel order all /// distinct -- decodes back to the same pixels a viewer would see, in RGBA.