From 5b643294af8237921b27f4905621acd7aea25539 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Thu, 2 May 2024 07:49:51 +0000 Subject: [PATCH] Use proper TRACE_EVENT_ASYNC_STEP macro with perfetto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no TRACE_EVENT_ASYNC_STEP in the perfetto legacy API. The corresponding legacy API that matches best is TRACE_EVENT_ASYNC_STEP_INTO. Bug: b/42226290 Change-Id: I6725973895878e34d96b6cd3314ab8de402a911b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/349120 Reviewed-by: Erik Språng Commit-Queue: Evan Shrubsole Reviewed-by: Mirko Bonadei Cr-Commit-Position: refs/heads/main@{#42219} --- modules/video_coding/deprecated/receiver.cc | 5 ++-- rtc_base/trace_event.h | 30 +++++++-------------- video/video_stream_encoder.cc | 4 +-- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/modules/video_coding/deprecated/receiver.cc b/modules/video_coding/deprecated/receiver.cc index b76084779d..a048f8487e 100644 --- a/modules/video_coding/deprecated/receiver.cc +++ b/modules/video_coding/deprecated/receiver.cc @@ -161,8 +161,9 @@ VCMEncodedFrame* VCMReceiver::FrameForDecoding(uint16_t max_wait_time_ms, return NULL; } frame->SetRenderTime(render_time_ms); - TRACE_EVENT_ASYNC_STEP1("webrtc", "Video", frame->RtpTimestamp(), - "SetRenderTS", "render_time", frame->RenderTimeMs()); + TRACE_EVENT_ASYNC_STEP_INTO1("webrtc", "Video", frame->RtpTimestamp(), + "SetRenderTS", "render_time", + frame->RenderTimeMs()); return frame; } diff --git a/rtc_base/trace_event.h b/rtc_base/trace_event.h index 4a2d234a67..3329abd66c 100644 --- a/rtc_base/trace_event.h +++ b/rtc_base/trace_event.h @@ -26,24 +26,10 @@ #include "third_party/perfetto/include/perfetto/tracing/track_event_args.h" // IWYU pragma: end_exports -#if defined(RTC_USE_PERFETTO) - -// TODO(webrtc:15917): Replace these events. -#define TRACE_EVENT_ASYNC_STEP0(category_group, name, id, step) \ - TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) -#define TRACE_EVENT_ASYNC_STEP1(category_group, name, id, step, arg1_name, \ - arg1_val) \ - TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, arg1_name, \ - arg1_val) - -#else - +#if !defined(RTC_USE_PERFETTO) #include #include "rtc_base/event_tracer.h" -#include "third_party/perfetto/include/perfetto/tracing/event_context.h" -#include "third_party/perfetto/include/perfetto/tracing/track.h" -#include "third_party/perfetto/include/perfetto/tracing/track_event_args.h" #define RTC_NOOP() \ do { \ @@ -352,13 +338,14 @@ static constexpr uint8_t TRACE_EVENT_SCOPE_THREAD = 2u << 2; // ASYNC_BEGIN event above. The `step` param identifies this step within the // async event. This should be called at the beginning of the next phase of an // asynchronous operation. -#define TRACE_EVENT_ASYNC_STEP0(category, name, id, step) \ +#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) \ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \ name, id, TRACE_EVENT_FLAG_NONE, "step", \ step) -#define TRACE_EVENT_ASYNC_STEP1(category, name, id, step, arg1_name, arg1_val) \ - INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \ - name, id, TRACE_EVENT_FLAG_NONE, "step", \ +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ + INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, category, \ + name, id, TRACE_EVENT_FLAG_NONE, "step", \ step, arg1_name, arg1_val) // Records a single ASYNC_END event for "name" immediately. If the category @@ -801,8 +788,9 @@ class TraceEndOnScopeClose { arg2_name, arg2_val) \ RTC_NOOP() -#define TRACE_EVENT_ASYNC_STEP0(category, name, id, step) RTC_NOOP() -#define TRACE_EVENT_ASYNC_STEP1(category, name, id, step, arg1_name, arg1_val) \ +#define TRACE_EVENT_ASYNC_STEP_INTO0(category, name, id, step) RTC_NOOP() +#define TRACE_EVENT_ASYNC_STEP_INTO1(category, name, id, step, arg1_name, \ + arg1_val) \ RTC_NOOP() #define TRACE_EVENT_ASYNC_END0(category, name, id) RTC_NOOP() diff --git a/video/video_stream_encoder.cc b/video/video_stream_encoder.cc index 706b4ce1c4..efc5df01bc 100644 --- a/video/video_stream_encoder.cc +++ b/video/video_stream_encoder.cc @@ -2009,8 +2009,8 @@ void VideoStreamEncoder::EncodeVideoFrame(const VideoFrame& video_frame, } accumulated_update_rect_is_valid_ = true; - TRACE_EVENT_ASYNC_STEP0("webrtc", "Video", video_frame.render_time_ms(), - "Encode"); + TRACE_EVENT_ASYNC_STEP_INTO0("webrtc", "Video", video_frame.render_time_ms(), + "Encode"); stream_resource_manager_.OnEncodeStarted(out_frame, time_when_posted_us);