Use proper TRACE_EVENT_ASYNC_STEP macro with perfetto

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 <sprang@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42219}
This commit is contained in:
Evan Shrubsole 2024-05-02 07:49:51 +00:00 committed by WebRTC LUCI CQ
parent 8410b6e9e6
commit 5b643294af
3 changed files with 14 additions and 25 deletions

View file

@ -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;
}

View file

@ -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 <string>
#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()

View file

@ -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);