aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIvan Molodetskikh <yalterz@gmail.com>2023-10-12 14:07:55 +0400
committerIvan Molodetskikh <yalterz@gmail.com>2023-10-12 14:07:55 +0400
commitcc259f9a34974dcef4d126dfd3277e0a8c9a180c (patch)
tree2c744d75d187d35afc3906d5e24243a478361c64
parent3602876b5e62ac64cc6ef7543e87c72b364939ee (diff)
downloadniri-cc259f9a34974dcef4d126dfd3277e0a8c9a180c.tar.gz
niri-cc259f9a34974dcef4d126dfd3277e0a8c9a180c.tar.bz2
niri-cc259f9a34974dcef4d126dfd3277e0a8c9a180c.zip
frame_clock: Defend against last presentation time being too much in the future
-rw-r--r--src/frame_clock.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/frame_clock.rs b/src/frame_clock.rs
index f7f55890..ad8cf2f7 100644
--- a/src/frame_clock.rs
+++ b/src/frame_clock.rs
@@ -52,8 +52,19 @@ impl FrameClock {
if now <= last_presentation_time {
// Got an early VBlank.
+ let orig_now = now;
now += Duration::from_nanos(refresh_interval_ns);
- // Assume two-frame early VBlanks don't happen. Overflow checks will catch them.
+
+ if now < last_presentation_time {
+ // Not sure when this can happen.
+ error!(
+ now = ?orig_now,
+ ?last_presentation_time,
+ "got a 2+ early VBlank, {:?} until presentation",
+ last_presentation_time - now,
+ );
+ now = last_presentation_time + Duration::from_nanos(refresh_interval_ns);
+ }
}
let since_last = now - last_presentation_time;