Commit d7309448 authored by caseq@chromium.org's avatar caseq@chromium.org

cc: add more devtools instrumentation

This adds didRequestMainThreadFrame() and didDrawFrame() so we can better
track impl-side frame lifecycle in DevTools

R=danakj, nduca

Review URL: https://codereview.chromium.org/144463016

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251127 0039d316-1c4b-4281-b951-d872f2087c98
parent f1ccb865
...@@ -20,6 +20,8 @@ const char kPixelRefId[] = "pixelRefId"; ...@@ -20,6 +20,8 @@ const char kPixelRefId[] = "pixelRefId";
const char kImageDecodeTask[] = "ImageDecodeTask"; const char kImageDecodeTask[] = "ImageDecodeTask";
const char kBeginFrame[] = "BeginFrame"; const char kBeginFrame[] = "BeginFrame";
const char kActivateLayerTree[] = "ActivateLayerTree"; const char kActivateLayerTree[] = "ActivateLayerTree";
const char kRequestMainThreadFrame[] = "RequestMainThreadFrame";
const char kDrawFrame[] = "DrawFrame";
} // namespace internal } // namespace internal
const char kRasterTask[] = "RasterTask"; const char kRasterTask[] = "RasterTask";
...@@ -86,7 +88,7 @@ struct ScopedLayerObjectTracker ...@@ -86,7 +88,7 @@ struct ScopedLayerObjectTracker
DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker); DISALLOW_COPY_AND_ASSIGN(ScopedLayerObjectTracker);
}; };
inline void didActivateLayerTree(int layer_tree_host_id, int frame_id) { inline void DidActivateLayerTree(int layer_tree_host_id, int frame_id) {
TRACE_EVENT_INSTANT2(internal::kCategory, TRACE_EVENT_INSTANT2(internal::kCategory,
internal::kActivateLayerTree, internal::kActivateLayerTree,
TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_SCOPE_THREAD,
...@@ -94,13 +96,29 @@ inline void didActivateLayerTree(int layer_tree_host_id, int frame_id) { ...@@ -94,13 +96,29 @@ inline void didActivateLayerTree(int layer_tree_host_id, int frame_id) {
internal::kFrameId, frame_id); internal::kFrameId, frame_id);
} }
inline void didBeginFrame(int layer_tree_host_id) { inline void DidBeginFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory, TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kBeginFrame, internal::kBeginFrame,
TRACE_EVENT_SCOPE_THREAD, TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId, layer_tree_host_id); internal::kLayerTreeId, layer_tree_host_id);
} }
inline void DidDrawFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kDrawFrame,
TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId,
layer_tree_host_id);
}
inline void DidRequestMainThreadFrame(int layer_tree_host_id) {
TRACE_EVENT_INSTANT1(internal::kCategory,
internal::kRequestMainThreadFrame,
TRACE_EVENT_SCOPE_THREAD,
internal::kLayerTreeId,
layer_tree_host_id);
}
} // namespace devtools_instrumentation } // namespace devtools_instrumentation
} // namespace cc } // namespace cc
......
...@@ -215,6 +215,7 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { ...@@ -215,6 +215,7 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
last_begin_impl_frame_args_ = args; last_begin_impl_frame_args_ = args;
last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate(); last_begin_impl_frame_args_.deadline -= client_->DrawDurationEstimate();
state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_); state_machine_.OnBeginImplFrame(last_begin_impl_frame_args_);
devtools_instrumentation::DidBeginFrame(layer_tree_host_id_);
if (settings_.switch_to_low_latency_if_possible) { if (settings_.switch_to_low_latency_if_possible) {
state_machine_.SetSkipBeginMainFrameToReduceLatency( state_machine_.SetSkipBeginMainFrameToReduceLatency(
...@@ -228,7 +229,6 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) { ...@@ -228,7 +229,6 @@ void Scheduler::BeginImplFrame(const BeginFrameArgs& args) {
return; return;
state_machine_.OnBeginImplFrameDeadlinePending(); state_machine_.OnBeginImplFrameDeadlinePending();
devtools_instrumentation::didBeginFrame(layer_tree_host_id_);
if (settings_.using_synchronous_renderer_compositor) { if (settings_.using_synchronous_renderer_compositor) {
// The synchronous renderer compositor has to make its GL calls // The synchronous renderer compositor has to make its GL calls
// within this call to BeginImplFrame. // within this call to BeginImplFrame.
......
...@@ -410,7 +410,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) { ...@@ -410,7 +410,7 @@ void LayerTreeHost::FinishCommitOnImplThread(LayerTreeHostImpl* host_impl) {
// If we're not in impl-side painting, the tree is immediately // If we're not in impl-side painting, the tree is immediately
// considered active. // considered active.
sync_tree->DidBecomeActive(); sync_tree->DidBecomeActive();
devtools_instrumentation::didActivateLayerTree(id_, source_frame_number_); devtools_instrumentation::DidActivateLayerTree(id_, source_frame_number_);
} }
micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl); micro_benchmark_controller_.ScheduleImplBenchmarks(host_impl);
......
...@@ -1343,7 +1343,6 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, ...@@ -1343,7 +1343,6 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
fps_counter_->SaveTimeStamp(frame_begin_time, fps_counter_->SaveTimeStamp(frame_begin_time,
!output_surface_->context_provider()); !output_surface_->context_provider());
bool on_main_thread = false; bool on_main_thread = false;
rendering_stats_instrumentation_->IncrementFrameCount( rendering_stats_instrumentation_->IncrementFrameCount(
1, on_main_thread); 1, on_main_thread);
...@@ -1437,6 +1436,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame, ...@@ -1437,6 +1436,7 @@ void LayerTreeHostImpl::DrawLayers(FrameData* frame,
} }
active_tree_->root_layer()->ResetAllChangeTrackingForSubtree(); active_tree_->root_layer()->ResetAllChangeTrackingForSubtree();
devtools_instrumentation::DidDrawFrame(id_);
BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent( BenchmarkInstrumentation::IssueImplThreadRenderingStatsEvent(
rendering_stats_instrumentation_->impl_thread_rendering_stats()); rendering_stats_instrumentation_->impl_thread_rendering_stats());
rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats(); rendering_stats_instrumentation_->AccumulateAndClearImplThreadStats();
...@@ -1635,8 +1635,8 @@ void LayerTreeHostImpl::ActivatePendingTree() { ...@@ -1635,8 +1635,8 @@ void LayerTreeHostImpl::ActivatePendingTree() {
if (time_source_client_adapter_ && time_source_client_adapter_->Active()) if (time_source_client_adapter_ && time_source_client_adapter_->Active())
DCHECK(active_tree_->root_layer()); DCHECK(active_tree_->root_layer());
devtools_instrumentation::didActivateLayerTree(id_, devtools_instrumentation::DidActivateLayerTree(
active_tree_->source_frame_number()); id_, active_tree_->source_frame_number());
} }
void LayerTreeHostImpl::SetVisible(bool visible) { void LayerTreeHostImpl::SetVisible(bool visible) {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "cc/base/swap_promise.h" #include "cc/base/swap_promise.h"
#include "cc/debug/benchmark_instrumentation.h" #include "cc/debug/benchmark_instrumentation.h"
#include "cc/debug/devtools_instrumentation.h"
#include "cc/input/input_handler.h" #include "cc/input/input_handler.h"
#include "cc/output/context_provider.h" #include "cc/output/context_provider.h"
#include "cc/output/output_surface.h" #include "cc/output/output_surface.h"
...@@ -84,7 +85,7 @@ ThreadProxy::ThreadProxy( ...@@ -84,7 +85,7 @@ ThreadProxy::ThreadProxy(
: Proxy(impl_task_runner), : Proxy(impl_task_runner),
main_thread_only_vars_unsafe_(this, layer_tree_host->id()), main_thread_only_vars_unsafe_(this, layer_tree_host->id()),
main_thread_or_blocked_vars_unsafe_(layer_tree_host), main_thread_or_blocked_vars_unsafe_(layer_tree_host),
compositor_thread_vars_unsafe_(this) { compositor_thread_vars_unsafe_(this, layer_tree_host->id()) {
TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy"); TRACE_EVENT0("cc", "ThreadProxy::ThreadProxy");
DCHECK(IsMainThread()); DCHECK(IsMainThread());
DCHECK(this->layer_tree_host()); DCHECK(this->layer_tree_host());
...@@ -120,8 +121,10 @@ ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() { ...@@ -120,8 +121,10 @@ ThreadProxy::MainThreadOrBlockedMainThread::contents_texture_manager() {
return layer_tree_host->contents_texture_manager(); return layer_tree_host->contents_texture_manager();
} }
ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy) ThreadProxy::CompositorThreadOnly::CompositorThreadOnly(ThreadProxy* proxy,
: contents_texture_manager(NULL), int layer_tree_host_id)
: layer_tree_host_id(layer_tree_host_id),
contents_texture_manager(NULL),
begin_main_frame_sent_completion_event(NULL), begin_main_frame_sent_completion_event(NULL),
readback_request(NULL), readback_request(NULL),
commit_completion_event(NULL), commit_completion_event(NULL),
...@@ -688,8 +691,7 @@ void ThreadProxy::Start() { ...@@ -688,8 +691,7 @@ void ThreadProxy::Start() {
FROM_HERE, FROM_HERE,
base::Bind(&ThreadProxy::InitializeImplOnImplThread, base::Bind(&ThreadProxy::InitializeImplOnImplThread,
base::Unretained(this), base::Unretained(this),
&completion, &completion));
main().layer_tree_host_id));
completion.Wait(); completion.Wait();
main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr(); main_thread_weak_ptr_ = main().weak_factory.GetWeakPtr();
...@@ -782,7 +784,8 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() { ...@@ -782,7 +784,8 @@ void ThreadProxy::ScheduledActionSendBeginMainFrame() {
base::Bind(&ThreadProxy::BeginMainFrame, base::Bind(&ThreadProxy::BeginMainFrame,
main_thread_weak_ptr_, main_thread_weak_ptr_,
base::Passed(&begin_main_frame_state))); base::Passed(&begin_main_frame_state)));
devtools_instrumentation::DidRequestMainThreadFrame(
impl().layer_tree_host_id);
if (impl().begin_main_frame_sent_completion_event) { if (impl().begin_main_frame_sent_completion_event) {
impl().begin_main_frame_sent_completion_event->Signal(); impl().begin_main_frame_sent_completion_event->Signal();
impl().begin_main_frame_sent_completion_event = NULL; impl().begin_main_frame_sent_completion_event = NULL;
...@@ -1443,8 +1446,7 @@ void ThreadProxy::HasInitializedOutputSurfaceOnImplThread( ...@@ -1443,8 +1446,7 @@ void ThreadProxy::HasInitializedOutputSurfaceOnImplThread(
completion->Signal(); completion->Signal();
} }
void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion) {
int layer_tree_host_id) {
TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread"); TRACE_EVENT0("cc", "ThreadProxy::InitializeImplOnImplThread");
DCHECK(IsImplThread()); DCHECK(IsImplThread());
impl().layer_tree_host_impl = impl().layer_tree_host_impl =
...@@ -1463,7 +1465,7 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion, ...@@ -1463,7 +1465,7 @@ void ThreadProxy::InitializeImplOnImplThread(CompletionEvent* completion,
scheduler_settings.throttle_frame_production = scheduler_settings.throttle_frame_production =
settings.throttle_frame_production; settings.throttle_frame_production;
impl().scheduler = impl().scheduler =
Scheduler::Create(this, scheduler_settings, layer_tree_host_id); Scheduler::Create(this, scheduler_settings, impl().layer_tree_host_id);
impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible()); impl().scheduler->SetVisible(impl().layer_tree_host_impl->visible());
impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr(); impl_thread_weak_ptr_ = impl().weak_factory.GetWeakPtr();
......
...@@ -167,8 +167,7 @@ class ThreadProxy : public Proxy, ...@@ -167,8 +167,7 @@ class ThreadProxy : public Proxy,
void BeginMainFrameAbortedOnImplThread(bool did_handle); void BeginMainFrameAbortedOnImplThread(bool did_handle);
void RequestReadbackOnImplThread(ReadbackRequest* request); void RequestReadbackOnImplThread(ReadbackRequest* request);
void FinishAllRenderingOnImplThread(CompletionEvent* completion); void FinishAllRenderingOnImplThread(CompletionEvent* completion);
void InitializeImplOnImplThread(CompletionEvent* completion, void InitializeImplOnImplThread(CompletionEvent* completion);
int layer_tree_host_id);
void SetLayerTreeHostClientReadyOnImplThread(); void SetLayerTreeHostClientReadyOnImplThread();
void SetVisibleOnImplThread(CompletionEvent* completion, bool visible); void SetVisibleOnImplThread(CompletionEvent* completion, bool visible);
void UpdateBackgroundAnimateTicking(); void UpdateBackgroundAnimateTicking();
...@@ -255,9 +254,11 @@ class ThreadProxy : public Proxy, ...@@ -255,9 +254,11 @@ class ThreadProxy : public Proxy,
const MainThreadOrBlockedMainThread& blocked_main() const; const MainThreadOrBlockedMainThread& blocked_main() const;
struct CompositorThreadOnly { struct CompositorThreadOnly {
explicit CompositorThreadOnly(ThreadProxy* proxy); CompositorThreadOnly(ThreadProxy* proxy, int layer_tree_host_id);
~CompositorThreadOnly(); ~CompositorThreadOnly();
const int layer_tree_host_id;
// Copy of the main thread side contents texture manager for work // Copy of the main thread side contents texture manager for work
// that needs to be done on the compositor thread. // that needs to be done on the compositor thread.
PrioritizedResourceManager* contents_texture_manager; PrioritizedResourceManager* contents_texture_manager;
......
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