[tracing] Keep track of frame coalescing in HostBeginFrameObserver
This CL adds trace events connected via flows to keep track of frames being coalesced in HostBeginFrameObserver. Bug: b:349975994 Change-Id: Ifcb5670d55e9dc96596f5734556302ad02eb3f7e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6352616 Auto-Submit: Petr Cermak <petrcermak@chromium.org> Reviewed-by: Jonathan Ross <jonross@chromium.org> Reviewed-by: Victor Miura <vmiura@chromium.org> Commit-Queue: Jonathan Ross <jonross@chromium.org> Cr-Commit-Position: refs/heads/main@{#1432198}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
5dcf1c2a12
commit
72d10f9f48
@ -7,8 +7,20 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/task/common/task_annotator.h"
|
||||
#include "base/time/time.h"
|
||||
#include "components/viz/common/frame_sinks/begin_frame_args.h"
|
||||
|
||||
namespace ui {
|
||||
namespace {
|
||||
|
||||
void WriteBeginFrameIdToTrace(perfetto::EventContext& ctx,
|
||||
const viz::BeginFrameId frame_id) {
|
||||
auto* event = ctx.event<perfetto::protos::pbzero::ChromeTrackEvent>();
|
||||
auto* begin_frame_id = event->set_begin_frame_id();
|
||||
begin_frame_id->set_source_id(frame_id.source_id);
|
||||
begin_frame_id->set_sequence_number(frame_id.sequence_number);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
HostBeginFrameObserver::HostBeginFrameObserver(
|
||||
SimpleBeginFrameObserverList& observers,
|
||||
@ -28,6 +40,11 @@ void HostBeginFrameObserver::OnStandaloneBeginFrame(
|
||||
}
|
||||
|
||||
if (pending_coalesce_callback_) {
|
||||
TRACE_EVENT_INSTANT("ui", "HostBeginFrameObserver::continue coalescing",
|
||||
perfetto::Flow::Global(coalesce_flow_id_),
|
||||
[&](perfetto::EventContext ctx) {
|
||||
WriteBeginFrameIdToTrace(ctx, args.frame_id);
|
||||
});
|
||||
begin_frame_args_ = args;
|
||||
return;
|
||||
}
|
||||
@ -35,6 +52,12 @@ void HostBeginFrameObserver::OnStandaloneBeginFrame(
|
||||
if ((base::TimeTicks::Now() - args.frame_time) > args.interval) {
|
||||
begin_frame_args_ = args;
|
||||
pending_coalesce_callback_ = true;
|
||||
coalesce_flow_id_ = base::trace_event::GetNextGlobalTraceId();
|
||||
TRACE_EVENT_INSTANT("ui", "HostBeginFrameObserver::start coalescing",
|
||||
perfetto::Flow::Global(coalesce_flow_id_),
|
||||
[&](perfetto::EventContext ctx) {
|
||||
WriteBeginFrameIdToTrace(ctx, args.frame_id);
|
||||
});
|
||||
task_runner_->PostDelayedTask(
|
||||
FROM_HERE,
|
||||
base::BindOnce(&HostBeginFrameObserver::CoalescedBeginFrame,
|
||||
@ -53,9 +76,16 @@ HostBeginFrameObserver::GetBoundRemote() {
|
||||
|
||||
void HostBeginFrameObserver::CoalescedBeginFrame() {
|
||||
DCHECK(begin_frame_args_.IsValid());
|
||||
TRACE_EVENT_INSTANT("ui", "HostBeginFrameObserver::finish coalescing",
|
||||
perfetto::Flow::Global(coalesce_flow_id_),
|
||||
[&](perfetto::EventContext ctx) {
|
||||
WriteBeginFrameIdToTrace(ctx,
|
||||
begin_frame_args_.frame_id);
|
||||
});
|
||||
pending_coalesce_callback_ = false;
|
||||
viz::BeginFrameArgs args = begin_frame_args_;
|
||||
begin_frame_args_ = viz::BeginFrameArgs();
|
||||
coalesce_flow_id_ = ~0ull;
|
||||
CallObservers(args);
|
||||
}
|
||||
|
||||
|
@ -55,6 +55,7 @@ class COMPOSITOR_EXPORT HostBeginFrameObserver
|
||||
|
||||
bool pending_coalesce_callback_ = false;
|
||||
viz::BeginFrameArgs begin_frame_args_;
|
||||
uint64_t coalesce_flow_id_ = ~0ull;
|
||||
|
||||
mojo::Receiver<viz::mojom::BeginFrameObserver> receiver_{this};
|
||||
base::WeakPtrFactory<HostBeginFrameObserver> weak_factory_{this};
|
||||
|
Reference in New Issue
Block a user