forge
Explore
Log in

Don't you dare go Hollow

A library preview finally has a pulse

Browse files at this commit

397bd838c011494b62bacb3ea97aff0f28c2401bAhmet Kaan GümüşParent: 0bee605
  • fix
    • a library preview finally has a pulse
Show full message
🐛 fix(app): a library preview finally has a pulse

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.rsmodified+1 -1
@@ -8,7 +8,7 @@ impl Render for Player {
8 // A file that has just been opened sits on its first frame with the8 // A file that has just been opened sits on its first frame with the
9 // clock stopped: opening is not playing, whichever way the file9 // clock stopped: opening is not playing, whichever way the file
10 // arrived. The play binding and the transport button start it.10 // arrived. The play binding and the transport button start it.
11- if let Some(session) = &mut self.session {11+ if let Some(session) = self.active_session_mut() {
12 session.tick();12 session.tick();
13 }13 }
14 self.pump(window);14 self.pump(window);
crates/app/src/tests/media.rsmodified+24 -0
@@ -1279,6 +1279,30 @@ fn a_second_session_playing_never_moves_the_first() {
1279 );1279 );
1280 }1280 }
1281 1281
1282+/// The frozen-preview regression: `render` used to call `tick` on
1283+/// `self.session` unconditionally, so a preview session's clock -- the one
1284+/// [`Player::pump`] actually reads while previewing -- was never advanced
1285+/// and the picture sat on frame 0 forever. The fix routes `tick` through
1286+/// [`Player::active_session_mut`], the same preview-first precedence
1287+/// `pump`/`transport` already use. This proves `tick` is what a session
1288+/// needs to keep its own clock honest, and that ticking one session leaves
1289+/// an untouched sibling exactly where it was -- so routing it through
1290+/// whichever session is active cannot disturb the other one.
1291+#[test]
1292+fn ticking_the_preview_session_never_moves_the_timeline() {
1293+ let mut timeline = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1294+ timeline.seek(0.5);
1295+ let before = timeline.now();
1296+
1297+ let mut preview = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1298+ preview.play();
1299+ // Stands in for what `render` now does every frame while a preview is
1300+ // showing: only the active session -- the preview -- gets ticked.
1301+ preview.tick();
1302+
1303+ assert_eq!(timeline.now(), before, "ticking the preview moved the timeline's clock");
1304+}
1305+
1282 /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a1306 /// [`bgra_to_rgba`] and [`save_screenshot`]'s own PNG write, round-tripped: a
1283 /// synthetic 2x2 frame -- one pixel per corner, alpha and channel order all1307 /// synthetic 2x2 frame -- one pixel per corner, alpha and channel order all
1284 /// distinct -- decodes back to the same pixels a viewer would see, in RGBA.1308 /// distinct -- decodes back to the same pixels a viewer would see, in RGBA.