forge
Explore
Log in

Don't you dare go Hollow

tty: Avoid zero estimated vblank timer

Browse files at this commit

0add457cf0b82fd3c2c85c488bd9e6171695fcbfIvan MolodetskikhParent: 6e5426e
src/backend/tty.rsmodified+16 -1
@@ -1649,7 +1649,22 @@ fn queue_estimated_vblank_timer(
16491649 }
16501650
16511651 let now = get_monotonic_time();
1652- let timer = Timer::from_duration(target_presentation_time.saturating_sub(now));
1652+ let mut duration = target_presentation_time.saturating_sub(now);
1653+
1654+ // No use setting a zero timer, since we'll send frame callbacks anyway right after the call to
1655+ // render(). This can happen for example with unknown presentation time from DRM.
1656+ if duration.is_zero() {
1657+ duration += output_state
1658+ .frame_clock
1659+ .refresh_interval()
1660+ // Unknown refresh interval, i.e. winit backend. Would be good to estimate it somehow
1661+ // but it's not that important for this code path.
1662+ .unwrap_or(Duration::from_micros(16_667));
1663+ }
1664+
1665+ trace!("queueing estimated vblank timer to fire in {duration:?}");
1666+
1667+ let timer = Timer::from_duration(duration);
16531668 let token = niri
16541669 .event_loop
16551670 .insert_source(timer, move |_, _, data| {