aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/tty.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/tty.rs b/src/backend/tty.rs
index 01f10fb6..117cb0da 100644
--- a/src/backend/tty.rs
+++ b/src/backend/tty.rs
@@ -1649,7 +1649,22 @@ fn queue_estimated_vblank_timer(
}
let now = get_monotonic_time();
- let timer = Timer::from_duration(target_presentation_time.saturating_sub(now));
+ let mut duration = target_presentation_time.saturating_sub(now);
+
+ // No use setting a zero timer, since we'll send frame callbacks anyway right after the call to
+ // render(). This can happen for example with unknown presentation time from DRM.
+ if duration.is_zero() {
+ duration += output_state
+ .frame_clock
+ .refresh_interval()
+ // Unknown refresh interval, i.e. winit backend. Would be good to estimate it somehow
+ // but it's not that important for this code path.
+ .unwrap_or(Duration::from_micros(16_667));
+ }
+
+ trace!("queueing estimated vblank timer to fire in {duration:?}");
+
+ let timer = Timer::from_duration(duration);
let token = niri
.event_loop
.insert_source(timer, move |_, _, data| {