[mutter] clutter/frame-clock: Add lateness to dispatch trace



commit 17bb0a3de4dcd24927140776e1b4caf2c2eb24ed
Author: Ivan Molodetskikh <yalterz gmail com>
Date:   Tue Dec 14 12:33:31 2021 +0300

    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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1928>

 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 31f5bb1257..6fa2b25887 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]