From 17bb0a3de4dcd24927140776e1b4caf2c2eb24ed Mon Sep 17 00:00:00 2001 From: Ivan Molodetskikh Date: Tue, 14 Dec 2021 12:33:31 +0300 Subject: [PATCH] clutter/frame-clock: Add lateness to dispatch trace To diagnose when missed frames are caused by dispatch being delayed rather than repaint scheduling producing the wrong dispatch time. Part-of: --- clutter/clutter/clutter-frame-clock.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/clutter/clutter/clutter-frame-clock.c b/clutter/clutter/clutter-frame-clock.c index 31f5bb125..6fa2b2588 100644 --- a/clutter/clutter/clutter-frame-clock.c +++ b/clutter/clutter/clutter-frame-clock.c @@ -657,8 +657,14 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock, ClutterFrameResult result; int64_t ideal_dispatch_time_us, lateness_us; +#ifdef COGL_HAS_TRACING + int64_t this_dispatch_ready_time_us; + COGL_TRACE_BEGIN_SCOPED (ClutterFrameClockDispatch, "Frame Clock (dispatch)"); + this_dispatch_ready_time_us = g_source_get_ready_time (frame_clock->source); +#endif + ideal_dispatch_time_us = (frame_clock->last_dispatch_time_us - frame_clock->last_dispatch_lateness_us) + frame_clock->refresh_interval_us; @@ -719,6 +725,17 @@ clutter_frame_clock_dispatch (ClutterFrameClock *frame_clock, } break; } + +#ifdef COGL_HAS_TRACING + if (this_dispatch_ready_time_us != -1 && + G_UNLIKELY (cogl_is_tracing_enabled ())) + { + g_autofree char *description = NULL; + description = g_strdup_printf ("dispatched %ld µs late", + time_us - this_dispatch_ready_time_us); + COGL_TRACE_DESCRIBE (ClutterFrameClockDispatch, description); + } +#endif } static gboolean