Enable the “Highlight Vsync” option in the timeline viewer on Android. (flutter/engine#3901)
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include "flutter/common/threads.h"
|
||||
#include "flutter/fml/platform/android/jni_util.h"
|
||||
#include "flutter/fml/platform/android/scoped_java_ref.h"
|
||||
#include "flutter/fml/trace_event.h"
|
||||
#include "lib/ftl/arraysize.h"
|
||||
#include "lib/ftl/logging.h"
|
||||
|
||||
@@ -39,7 +40,6 @@ void VsyncWaiterAndroid::AsyncWaitForVsync(Callback callback) {
|
||||
void VsyncWaiterAndroid::OnVsync(long frameTimeNanos) {
|
||||
Callback callback = std::move(callback_);
|
||||
callback_ = Callback();
|
||||
|
||||
blink::Threads::UI()->PostTask([callback, frameTimeNanos] {
|
||||
callback(ftl::TimePoint::FromEpochDelta(
|
||||
ftl::TimeDelta::FromNanoseconds(frameTimeNanos)));
|
||||
@@ -50,12 +50,19 @@ static void OnNativeVsync(JNIEnv* env,
|
||||
jclass jcaller,
|
||||
jlong frameTimeNanos,
|
||||
jlong cookie) {
|
||||
// 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
|
||||
TRACE_EVENT0("flutter", "VSYNC");
|
||||
TRACE_EVENT_INSTANT0("flutter", "VSYNC");
|
||||
ftl::WeakPtr<VsyncWaiterAndroid>* weak =
|
||||
reinterpret_cast<ftl::WeakPtr<VsyncWaiterAndroid>*>(cookie);
|
||||
VsyncWaiterAndroid* waiter = weak->get();
|
||||
delete weak;
|
||||
if (waiter)
|
||||
if (waiter) {
|
||||
waiter->OnVsync(frameTimeNanos);
|
||||
}
|
||||
}
|
||||
|
||||
bool VsyncWaiterAndroid::Register(JNIEnv* env) {
|
||||
|
||||
Reference in New Issue
Block a user