From 0c1e21728750bfe121bd91c78f6b2e143d6eeada Mon Sep 17 00:00:00 2001 From: Carlo Bernaschina Date: Thu, 14 Sep 2017 20:18:07 -0700 Subject: [PATCH] Add anchor events for developer centric timeline (#4105) By adding these events the new developer centric timeline will be able to identify and correlate events related to the different stages of the drawing pipeline. Roll Dart to 62045a4590a333ae557f8f261a909ee75449cd70 --- DEPS | 2 +- runtime/runtime_controller.cc | 9 ++++--- shell/common/animator.cc | 27 ++++++++++++++----- shell/common/animator.h | 2 ++ .../platform/android/vsync_waiter_android.cc | 13 +++++++-- .../ios/framework/Source/vsync_waiter_ios.mm | 15 +++++++++++ travis/licenses_golden/licenses_dart | 7 ++++- 7 files changed, 61 insertions(+), 14 deletions(-) diff --git a/DEPS b/DEPS index c716630e453..191132eef41 100644 --- a/DEPS +++ b/DEPS @@ -30,7 +30,7 @@ vars = { # Dart is: https://github.com/dart-lang/sdk/blob/master/DEPS. # You can use //tools/dart/create_updated_flutter_deps.py to produce # updated revision list of existing dependencies. - 'dart_revision': 'd9a26967e0b73191b158fcdff2dc8bc303c06a1b', + 'dart_revision': '62045a4590a333ae557f8f261a909ee75449cd70', 'dart_args_tag': '0.13.7', 'dart_async_tag': 'daf66909019d2aaec1721fc39d94ea648a9fdc1d', diff --git a/runtime/runtime_controller.cc b/runtime/runtime_controller.cc index 64457934b10..563c6b25c46 100644 --- a/runtime/runtime_controller.cc +++ b/runtime/runtime_controller.cc @@ -88,19 +88,22 @@ void RuntimeController::NotifyIdle(int64_t deadline) { void RuntimeController::DispatchPlatformMessage( fxl::RefPtr message) { - TRACE_EVENT0("flutter", "RuntimeController::DispatchPlatformMessage"); + TRACE_EVENT1("flutter", "RuntimeController::DispatchPlatformMessage", "mode", + "basic"); GetWindow()->DispatchPlatformMessage(std::move(message)); } void RuntimeController::DispatchPointerDataPacket( const PointerDataPacket& packet) { - TRACE_EVENT0("flutter", "RuntimeController::DispatchPointerDataPacket"); + TRACE_EVENT1("flutter", "RuntimeController::DispatchPointerDataPacket", + "mode", "basic"); GetWindow()->DispatchPointerDataPacket(packet); } void RuntimeController::DispatchSemanticsAction(int32_t id, SemanticsAction action) { - TRACE_EVENT0("flutter", "RuntimeController::DispatchSemanticsAction"); + TRACE_EVENT1("flutter", "RuntimeController::DispatchSemanticsAction", "mode", + "basic"); GetWindow()->DispatchSemanticsAction(id, action); } diff --git a/shell/common/animator.cc b/shell/common/animator.cc index fd2cfef2aa0..84b9b6c4f96 100644 --- a/shell/common/animator.cc +++ b/shell/common/animator.cc @@ -41,6 +41,12 @@ void Animator::Start() { RequestFrame(); } +// This Parity is used by the timeline component to correctly align +// GPU Workloads events with their respective Framework Workload. +const char* Animator::FrameParity() { + return (frame_number_ % 2) ? "even" : "odd"; +} + static int64_t FxlToDartOrEarlier(fxl::TimePoint time) { int64_t dart_now = Dart_TimelineGetMicros(); fxl::TimePoint fxl_now = fxl::TimePoint::Now(); @@ -76,7 +82,11 @@ void Animator::BeginFrame(fxl::TimePoint frame_start_time, last_begin_frame_time_ = frame_start_time; dart_frame_deadline_ = FxlToDartOrEarlier(frame_target_time); - engine_->BeginFrame(last_begin_frame_time_); + { + TRACE_EVENT2("flutter", "Framework Workload", "mode", "basic", "frame", + FrameParity()); + engine_->BeginFrame(last_begin_frame_time_); + } if (!frame_scheduled_) { // We don't have another frame pending, so we're waiting on user input @@ -95,12 +105,15 @@ void Animator::Render(std::unique_ptr layer_tree) { // Commit the pending continuation. producer_continuation_.Complete(std::move(layer_tree)); - blink::Threads::Gpu()->PostTask( - [ rasterizer = rasterizer_, pipeline = layer_tree_pipeline_ ]() { - if (!rasterizer.get()) - return; - rasterizer->Draw(pipeline); - }); + blink::Threads::Gpu()->PostTask([ + rasterizer = rasterizer_, pipeline = layer_tree_pipeline_, + frame_id = FrameParity() + ]() { + if (!rasterizer.get()) + return; + TRACE_EVENT2("flutter", "GPU Workload", "mode", "basic", "frame", frame_id); + rasterizer->Draw(pipeline); + }); } void Animator::RequestFrame() { diff --git a/shell/common/animator.h b/shell/common/animator.h index 010f3dfe3d8..ad8810b2599 100644 --- a/shell/common/animator.h +++ b/shell/common/animator.h @@ -40,6 +40,8 @@ class Animator { void AwaitVSync(); + const char* FrameParity(); + fxl::WeakPtr rasterizer_; VsyncWaiter* waiter_; Engine* engine_; diff --git a/shell/platform/android/vsync_waiter_android.cc b/shell/platform/android/vsync_waiter_android.cc index 7df245530f8..2b316cd5562 100644 --- a/shell/platform/android/vsync_waiter_android.cc +++ b/shell/platform/android/vsync_waiter_android.cc @@ -4,6 +4,7 @@ #include "flutter/shell/platform/android/vsync_waiter_android.h" +#include #include #include "flutter/common/threads.h" @@ -59,8 +60,16 @@ static void OnNativeVsync(JNIEnv* env, // Vsync" checkbox in the timeline can be enabled. // See: https://github.com/catapult-project/catapult/blob/2091404475cbba9b786 // 442979b6ec631305275a6/tracing/tracing/extras/vsync/vsync_auditor.html#L26 - TRACE_EVENT0("flutter", "VSYNC"); - TRACE_EVENT_INSTANT0("flutter", "VSYNC"); +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE + TRACE_EVENT1("flutter", "VSYNC", "mode", "basic"); +#else + { + constexpr size_t num_chars = sizeof(jlong) * CHAR_BIT * 3.4 + 2; + char deadline[num_chars]; + sprintf(deadline, "%lld", frameTargetTimeNanos / 1000); // microseconds + TRACE_EVENT2("flutter", "VSYNC", "mode", "basic", "deadline", deadline); + } +#endif fxl::WeakPtr* weak = reinterpret_cast*>(cookie); VsyncWaiterAndroid* waiter = weak->get(); diff --git a/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm b/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm index 264a83d3f7f..922674512ae 100644 --- a/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm +++ b/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm @@ -52,6 +52,21 @@ _displayLink.paused = YES; + // Note: The tag name must be "VSYNC" (it is special) so that the "Highlight + // Vsync" checkbox in the timeline can be enabled. + // See: https://github.com/catapult-project/catapult/blob/2091404475cbba9b786 + // 442979b6ec631305275a6/tracing/tracing/extras/vsync/vsync_auditor.html#L26 +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE + TRACE_EVENT1("flutter", "VSYNC", "mode", "basic"); +#else + { + constexpr size_t num_chars = sizeof(fxl::TimePoint) * CHAR_BIT * 3.4 + 2; + char deadline[num_chars]; + sprintf(deadline, "%lld", frame_target_time / 1000); // microseconds + TRACE_EVENT2("flutter", "VSYNC", "mode", "basic", "deadline", deadline); + } +#endif + // Note: Even though we know we are on the UI thread already (since the // display link was scheduled on the UI thread in the contructor), we use // the PostTask mechanism because the callback may have side-effects that need diff --git a/travis/licenses_golden/licenses_dart b/travis/licenses_golden/licenses_dart index 9eddf64340e..540f63617dc 100644 --- a/travis/licenses_golden/licenses_dart +++ b/travis/licenses_golden/licenses_dart @@ -1,4 +1,4 @@ -Signature: 6acb5ec35f946b04626e9b127e818708 +Signature: 1dbfd20015aaf7761e4f14c34f720089 UNUSED LICENSES: @@ -1499,6 +1499,8 @@ FILE: ../../../dart/runtime/bin/error_exit.h FILE: ../../../dart/runtime/bin/gzip.cc FILE: ../../../dart/runtime/bin/gzip.h FILE: ../../../dart/runtime/bin/isolate_data.cc +FILE: ../../../dart/runtime/bin/main_options.cc +FILE: ../../../dart/runtime/bin/main_options.h FILE: ../../../dart/runtime/bin/namespace.cc FILE: ../../../dart/runtime/bin/namespace.h FILE: ../../../dart/runtime/bin/namespace_android.cc @@ -1507,6 +1509,8 @@ FILE: ../../../dart/runtime/bin/namespace_linux.cc FILE: ../../../dart/runtime/bin/namespace_macos.cc FILE: ../../../dart/runtime/bin/namespace_patch.dart FILE: ../../../dart/runtime/bin/namespace_win.cc +FILE: ../../../dart/runtime/bin/options.cc +FILE: ../../../dart/runtime/bin/options.h FILE: ../../../dart/runtime/bin/secure_socket_filter.cc FILE: ../../../dart/runtime/bin/secure_socket_filter.h FILE: ../../../dart/runtime/bin/secure_socket_utils.cc @@ -1593,6 +1597,7 @@ FILE: ../../../dart/runtime/vm/timeline_win.cc FILE: ../../../dart/runtime/vm/zone_text_buffer.cc FILE: ../../../dart/runtime/vm/zone_text_buffer.h FILE: ../../../dart/sdk/lib/internal/linked_list.dart +FILE: ../../../dart/sdk/lib/io/embedder_config.dart FILE: ../../../dart/sdk/lib/io/namespace_impl.dart FILE: ../../../dart/sdk/lib/io/sync_socket.dart FILE: ../../../dart/sdk/lib/vmservice/named_lookup.dart