Commit b2fd68e9 authored by Alexander Timin's avatar Alexander Timin Committed by Commit Bot

Add flow event for Android surface transaction flow.

Add a pair of flow events connecting the place where the surface
transaction callback was set and where it was invoked.

This (together with other flow events) allows tracing the entire chain
of events which generated a given frame.

R=skyostil@chromium.org
BUG=1142207

Change-Id: I6f41fd6627c3ac9b2799d5574ed98ca8c619a014
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2494814
Commit-Queue: Alexander Timin <altimin@chromium.org>
Reviewed-by: default avatarSami Kyöstilä <skyostil@chromium.org>
Cr-Commit-Position: refs/heads/master@{#829025}
parent 2975deec
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/atomic_sequence_num.h" #include "base/atomic_sequence_num.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/debug/crash_logging.h" #include "base/debug/crash_logging.h"
#include "base/hash/md5_constexpr.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/no_destructor.h" #include "base/no_destructor.h"
...@@ -282,6 +283,12 @@ struct TransactionAckCtx { ...@@ -282,6 +283,12 @@ struct TransactionAckCtx {
SurfaceControl::Transaction::OnCompleteCb callback; SurfaceControl::Transaction::OnCompleteCb callback;
}; };
uint64_t GetTraceIdForTransaction(int transaction_id) {
constexpr uint64_t kMask =
base::MD5Hash64Constexpr("SurfaceControl::Transaction");
return kMask ^ transaction_id;
}
// Note that the framework API states that this callback can be dispatched on // Note that the framework API states that this callback can be dispatched on
// any thread (in practice it should be the binder thread). // any thread (in practice it should be the binder thread).
void OnTransactionCompletedOnAnyThread(void* context, void OnTransactionCompletedOnAnyThread(void* context,
...@@ -290,6 +297,9 @@ void OnTransactionCompletedOnAnyThread(void* context, ...@@ -290,6 +297,9 @@ void OnTransactionCompletedOnAnyThread(void* context,
auto transaction_stats = ToTransactionStats(stats); auto transaction_stats = ToTransactionStats(stats);
TRACE_EVENT_NESTABLE_ASYNC_END0("gpu,benchmark", "SurfaceControlTransaction", TRACE_EVENT_NESTABLE_ASYNC_END0("gpu,benchmark", "SurfaceControlTransaction",
ack_ctx->id); ack_ctx->id);
TRACE_EVENT_WITH_FLOW0(
"toplevel.flow", "gfx::SurfaceControlTransaction completed",
GetTraceIdForTransaction(ack_ctx->id), TRACE_EVENT_FLAG_FLOW_IN);
if (ack_ctx->task_runner) { if (ack_ctx->task_runner) {
ack_ctx->task_runner->PostTask( ack_ctx->task_runner->PostTask(
...@@ -301,6 +311,7 @@ void OnTransactionCompletedOnAnyThread(void* context, ...@@ -301,6 +311,7 @@ void OnTransactionCompletedOnAnyThread(void* context,
delete ack_ctx; delete ack_ctx;
} }
} // namespace } // namespace
// static // static
...@@ -472,6 +483,9 @@ void SurfaceControl::Transaction::SetFrameRate(const Surface& surface, ...@@ -472,6 +483,9 @@ void SurfaceControl::Transaction::SetFrameRate(const Surface& surface,
void SurfaceControl::Transaction::SetOnCompleteCb( void SurfaceControl::Transaction::SetOnCompleteCb(
OnCompleteCb cb, OnCompleteCb cb,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
TRACE_EVENT_WITH_FLOW0(
"toplevel.flow", "gfx::SurfaceControl::Transaction::SetOnCompleteCb",
GetTraceIdForTransaction(id_), TRACE_EVENT_FLAG_FLOW_OUT);
TransactionAckCtx* ack_ctx = new TransactionAckCtx; TransactionAckCtx* ack_ctx = new TransactionAckCtx;
ack_ctx->callback = std::move(cb); ack_ctx->callback = std::move(cb);
ack_ctx->task_runner = std::move(task_runner); ack_ctx->task_runner = std::move(task_runner);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment