From 06a249897bc76ade98a7fa2d3f5c4de3ea31870d Mon Sep 17 00:00:00 2001 From: Andri Yngvason Date: Sun, 26 Apr 2020 13:55:20 +0000 Subject: [PATCH] dmabuf: Show a debug message when frames are held for too long. --- include/dmabuf.h | 1 + src/dmabuf.c | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/dmabuf.h b/include/dmabuf.h index 36345bd..b70c228 100644 --- a/include/dmabuf.h +++ b/include/dmabuf.h @@ -49,6 +49,7 @@ struct dmabuf_capture { struct zwlr_export_dmabuf_manager_v1* manager; struct zwlr_export_dmabuf_frame_v1* zwlr_frame; struct dmabuf_frame frame; + uint64_t render_finish_time; }; void dmabuf_capture_init(struct dmabuf_capture* self); diff --git a/src/dmabuf.c b/src/dmabuf.c index 40b3d9c..f9b932c 100644 --- a/src/dmabuf.c +++ b/src/dmabuf.c @@ -17,8 +17,10 @@ #include #include #include +#include #include #include +#include #include "frame-capture.h" #include "logging.h" @@ -27,6 +29,8 @@ #include "render.h" #include "usdt.h" +#define PROCESSING_DURATION_LIMIT 16 /* ms */ + static void dmabuf_close_fds(struct dmabuf_capture* self) { for (size_t i = 0; i < self->frame.n_planes; ++i) @@ -101,7 +105,14 @@ static void dmabuf_frame_ready(void* data, struct dmabuf_capture* self = data; struct frame_capture* fc = data; - DTRACE_PROBE1(wayvnc, dmabuf_frame_ready, self); + struct timespec ts = { + .tv_sec = ((uint64_t)tv_sec_hi << 32) | tv_sec_lo, + .tv_nsec = tv_nsec + }; + + uint64_t precommit_time = timespec_to_ms(&ts); + + DTRACE_PROBE2(wayvnc, dmabuf_frame_ready, self, precommit_time); dmabuf_capture_stop(fc); @@ -109,6 +120,16 @@ static void dmabuf_frame_ready(void* data, fc->on_done(fc); dmabuf_close_fds(self); + + uint64_t processing_duration = + self->render_finish_time - precommit_time; + + DTRACE_PROBE3(wayvnc, dmabuf_frame_release, self, + self->render_finish_time, processing_duration); + + if (processing_duration > PROCESSING_DURATION_LIMIT) + log_debug("Processing dmabuf took %"PRIu64" ms.\n", + processing_duration); } static void dmabuf_frame_cancel(void* data, @@ -164,6 +185,7 @@ static void dmabuf_capture_render(struct frame_capture* fc, { struct dmabuf_capture* self = (void*)fc; render_dmabuf(render, &self->frame); + self->render_finish_time = gettime_ms(); } void dmabuf_capture_init(struct dmabuf_capture* self)