diff options
| author | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-01 08:27:44 +0400 |
|---|---|---|
| committer | Ivan Molodetskikh <yalterz@gmail.com> | 2024-03-01 08:27:44 +0400 |
| commit | 0add457cf0b82fd3c2c85c488bd9e6171695fcbf (patch) | |
| tree | 512b51d6ddc23fadc41f1f830e2e134ec99bc9e6 /src | |
| parent | 6e5426ef225f5720a97cf7e2def25132bfc2cf0c (diff) | |
| download | niri-0add457cf0b82fd3c2c85c488bd9e6171695fcbf.tar.gz niri-0add457cf0b82fd3c2c85c488bd9e6171695fcbf.tar.bz2 niri-0add457cf0b82fd3c2c85c488bd9e6171695fcbf.zip | |
tty: Avoid zero estimated vblank timer
Diffstat (limited to 'src')
| -rw-r--r-- | src/backend/tty.rs | 17 |
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| { |
