Skip to content

Commit

Permalink
Fix wrong VSYNC event (flutter#36775)
Browse files Browse the repository at this point in the history
  • Loading branch information
fzyzcjy authored Oct 29, 2022
1 parent 21d74d6 commit 9ccaa33
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions shell/common/vsync_waiter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,17 @@ void VsyncWaiter::FireCallback(fml::TimePoint frame_start_time,
bool pause_secondary_tasks) {
FML_DCHECK(fml::TimePoint::Now() >= frame_start_time);

// The event named "VSYNC" is special in `chrome://tracing` tool - it will
// 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, {}, {});

Callback callback;
std::vector<fml::closure> secondary_callbacks;

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

0 comments on commit 9ccaa33

Please sign in to comment.