From 1dbf25afa15779d922ed66ddfb8bcda205ae7494 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 7 Jun 2019 12:12:55 -0300 Subject: [PATCH] clutter/stage-cogl: Protect against extremely high refresh rates After 4faeb12731b8, the maximum time allowed for an update to happen is calculated as: max_render_time_allowed = refresh_interval - 1000 * sync_delay; However, extremely small refresh intervals -- that come as consequence to extremely high refresh rates -- may fall into an odd numerical range when refresh_interval < 1000 * sync_delay. That would give us a negative time. To be extra cautious about it, add another sanity check for this case. Change suggested by Jasper St. Pierre. https://gitlab.gnome.org/GNOME/mutter/merge_requests/363 --- clutter/clutter/cogl/clutter-stage-cogl.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/clutter/clutter/cogl/clutter-stage-cogl.c b/clutter/clutter/cogl/clutter-stage-cogl.c index 03f067267..5b6eeb8bf 100644 --- a/clutter/clutter/cogl/clutter-stage-cogl.c +++ b/clutter/clutter/cogl/clutter-stage-cogl.c @@ -199,6 +199,17 @@ clutter_stage_cogl_schedule_update (ClutterStageWindow *stage_window, min_render_time_allowed = refresh_interval / 2; max_render_time_allowed = refresh_interval - 1000 * sync_delay; + /* Be robust in the case of incredibly bogus refresh rate */ + if (max_render_time_allowed <= 0) + { + g_warning ("Unsupported monitor refresh rate detected. " + "(Refresh rate: %.3f, refresh interval: %ld)", + refresh_rate, + refresh_interval); + stage_cogl->update_time = now; + return; + } + if (min_render_time_allowed > max_render_time_allowed) min_render_time_allowed = max_render_time_allowed;