From 40e7e5d35646bbe2e79fd8bc0d32a3bd920e4673 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 22 Mar 2019 18:54:20 +0100 Subject: [PATCH] renderer-native: Fix page flip retry timeout calculation It tried to add a (implicitly casted) float to a uint64_t, and due to floating point precision issues resulted in timestamps intended to be in the future to actually be in the past. Fix this by first casting the delay to an uint64_t, then add it to the time stamp. https://gitlab.gnome.org/GNOME/mutter/merge_requests/506 --- src/backends/native/meta-renderer-native.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index e030e9518..d0de9d0d0 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1576,7 +1576,7 @@ retry_page_flips (gpointer user_data) g_error_matches (error, G_IO_ERROR, G_IO_ERROR_BUSY)) { retry_page_flip_data->retry_time_us += - G_USEC_PER_SEC / crtc->current_mode->refresh_rate; + (uint64_t) (G_USEC_PER_SEC / crtc->current_mode->refresh_rate); l = l_next; continue; } @@ -1660,7 +1660,7 @@ schedule_retry_page_flip (MetaOnscreenNative *onscreen_native, now_us = g_get_monotonic_time (); retry_time_us = - now_us + (G_USEC_PER_SEC / crtc->current_mode->refresh_rate); + now_us + (uint64_t) (G_USEC_PER_SEC / crtc->current_mode->refresh_rate); retry_page_flip_data = g_new0 (RetryPageFlipData, 1); retry_page_flip_data->crtc = crtc;