Preview: a stall after playing at full rate still steps down a resolution

The step-down was skipped while the achieved frame rate read as keeping up, and that rate comes from the frames shown in the last second they were shown: through a stall it kept the rate from before it, so a preview that played a cached stretch and then stalled never stepped down. A rate whose last frame is more than a second old no longer counts.
This commit is contained in:
nazar-gavrylyk
2026-11-10 15:58:42 +01:00
parent a10c7fa2cd
commit e356e4adf5
2 changed files with 26 additions and 1 deletions
+2 -1
View File
@@ -553,7 +553,8 @@ impl EffectcraftApp {
|| pb.res.is_some()
|| !self.viewer_res().is_auto()
|| now - since < 2.0
|| pb.achieved_fps().is_some_and(|f| f * step >= pb.fps * 0.8)
// (a rate from before a stall: nothing shown for a second isn't keeping up)
|| (pb.shown_at.back().is_some_and(|t| now - t <= 1.0) && pb.achieved_fps().is_some_and(|f| f * step >= pb.fps * 0.8))
|| lower < self.session.prefs.adaptive_limit() - 1e-9
{
return;
@@ -320,6 +320,30 @@ fn cache_frames_when_idle_survives_an_inverted_work_area() {
assert!(!h.state().playback.playing);
}
/// A preview that played at full rate and then stalls on frames that aren't cached still steps
/// down: the rate from before the stall doesn't count once nothing was shown for a second. (The
/// last second shown kept reading as full rate through the stall, and it never stepped down.)
#[test]
fn playback_that_stalls_after_keeping_up_steps_down() {
let mut h = harness();
h.state_mut().session.prefs.previews.adaptive_playback = true;
h.state().frames.set_budget(0);
h.state_mut().use_manual_clock();
invoke(&mut h, "playback.toggle", json!({}));
h.step();
assert!(h.state().playback.playing);
// A second shown at the comp's rate, just before the stall.
let t0 = h.state().now();
for i in 0..30 {
h.state_mut().playback.frame_shown(t0 - 1.0 + f64::from(i) / 30.0);
}
for _ in 0..25 {
h.state_mut().clock_mut().advance(0.1);
h.step();
}
assert_eq!(h.state().viewer_scale(1.0, 1.0), 0.5);
}
/// Settings ▸ Previews ▸ Lower Resolution When Playback Can't Keep Up: a preview at Auto that
/// stalls for two seconds steps down to half its scale, two more to a quarter; an explicit Resolution and
/// the pref turned off (its default) keep the scale, and stopping goes back to the viewer's.