Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions shell/common/vsync_waiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,17 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
return;
}

// The event named "VSYNC" is special in `chrome://tracing` tool - it will
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why here?

This means the event won't get emitted on vsyncs where there's no callback, right?

I think making this more accurate is a good idea, but probably should fire unconditionally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right! I have not thought about this problem before. Let me change it (probably within hours)

// have a zebra visualization.
fml::tracing::TraceTimelineEvent(
"flutter", "VSYNC", frame_start_time.ToEpochDelta().ToMicroseconds(), 0,
Dart_Timeline_Event_Begin, {"frame_start_time", "frame_target_time"},
{std::to_string(frame_start_time.ToEpochDelta().ToMicroseconds()),
std::to_string(frame_target_time.ToEpochDelta().ToMicroseconds())});
fml::tracing::TraceTimelineEvent(
"flutter", "VSYNC", frame_target_time.ToEpochDelta().ToMicroseconds(), 0,
Dart_Timeline_Event_End, {}, {});

if (callback) {
auto flow_identifier = fml::tracing::TraceNonce();
if (pause_secondary_tasks) {
Expand Down
2 changes: 1 addition & 1 deletion shell/common/vsync_waiter_fallback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ VsyncWaiterFallback::~VsyncWaiterFallback() = default;

// |VsyncWaiter|
void VsyncWaiterFallback::AwaitVSync() {
TRACE_EVENT0("flutter", "VSYNC");
TRACE_EVENT0("flutter", "VsyncCallback");

constexpr fml::TimeDelta kSingleFrameInterval =
fml::TimeDelta::FromSecondsF(1.0 / 60.0);
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/android/vsync_waiter_android.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void VsyncWaiterAndroid::AwaitVSync() {

// static
void VsyncWaiterAndroid::OnVsyncFromNDK(int64_t frame_nanos, void* data) {
TRACE_EVENT0("flutter", "VSYNC");
TRACE_EVENT0("flutter", "VsyncCallback");

auto frame_time = fml::TimePoint::FromEpochDelta(
fml::TimeDelta::FromNanoseconds(frame_nanos));
Expand All @@ -72,7 +72,7 @@ void VsyncWaiterAndroid::OnVsyncFromJava(JNIEnv* env,
jlong frameDelayNanos,
jlong refreshPeriodNanos,
jlong java_baton) {
TRACE_EVENT0("flutter", "VSYNC");
TRACE_EVENT0("flutter", "VsyncCallback");

auto frame_time =
fml::TimePoint::Now() - fml::TimeDelta::FromNanoseconds(frameDelayNanos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ - (void)pause {
}

- (void)onDisplayLink:(CADisplayLink*)link {
TRACE_EVENT0("flutter", "VSYNC");
TRACE_EVENT0("flutter", "VsyncCallback");

CFTimeInterval delay = CACurrentMediaTime() - link.timestamp;
fml::TimePoint frame_start_time = fml::TimePoint::Now() - fml::TimeDelta::FromSecondsF(delay);
Expand Down