Skip to content

Commit

Permalink
Add anchor events for developer centric timeline (flutter#4105)
Browse files Browse the repository at this point in the history
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 62045a4
  • Loading branch information
B3rn475 authored Sep 15, 2017
1 parent 0e8ffa2 commit 0c1e217
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
9 changes: 6 additions & 3 deletions runtime/runtime_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,22 @@ void RuntimeController::NotifyIdle(int64_t deadline) {

void RuntimeController::DispatchPlatformMessage(
fxl::RefPtr<PlatformMessage> 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);
}

Expand Down
27 changes: 20 additions & 7 deletions shell/common/animator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand All @@ -95,12 +105,15 @@ void Animator::Render(std::unique_ptr<flow::LayerTree> 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() {
Expand Down
2 changes: 2 additions & 0 deletions shell/common/animator.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Animator {

void AwaitVSync();

const char* FrameParity();

fxl::WeakPtr<Rasterizer> rasterizer_;
VsyncWaiter* waiter_;
Engine* engine_;
Expand Down
13 changes: 11 additions & 2 deletions shell/platform/android/vsync_waiter_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "flutter/shell/platform/android/vsync_waiter_android.h"

#include <cmath>
#include <utility>

#include "flutter/common/threads.h"
Expand Down Expand Up @@ -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<VsyncWaiterAndroid>* weak =
reinterpret_cast<fxl::WeakPtr<VsyncWaiterAndroid>*>(cookie);
VsyncWaiterAndroid* waiter = weak->get();
Expand Down
15 changes: 15 additions & 0 deletions shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ - (void)onDisplayLink:(CADisplayLink*)link {

_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
Expand Down
7 changes: 6 additions & 1 deletion travis/licenses_golden/licenses_dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Signature: 6acb5ec35f946b04626e9b127e818708
Signature: 1dbfd20015aaf7761e4f14c34f720089

UNUSED LICENSES:

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0c1e217

Please sign in to comment.