tty: Avoid zero estimated vblank timer
Browse files at this commit0add457cf0b82fd3c2c85c488bd9e6171695fcbfParent: 6e5426e1 changed file +16 -1
- src/backend/tty.rs +16 -1
src/backend/tty.rsmodified+16 -1
| @@ -1649,7 +1649,22 @@ fn queue_estimated_vblank_timer( | ||
| 1649 | 1649 | } |
| 1650 | 1650 | |
| 1651 | 1651 | 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); | |
| 1653 | 1668 | let token = niri |
| 1654 | 1669 | .event_loop |
| 1655 | 1670 | .insert_source(timer, move |_, _, data| { |