summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vishnu Nair <vishnun@google.com> 2024-07-15 20:26:17 +0000
committer Vishnu Nair <vishnun@google.com> 2024-07-16 18:48:08 +0000
commit1a761a62dc3b290079daece9a25b85d7e7d36db6 (patch)
tree63c147fb957eaa4d020d44f4822556fef6614b0e
parent266b176e67fb6378d3465fa2ca93f196efe25974 (diff)
Add tracepoints when clients use vsyncids from a different choreographer
Clients may get a stale vysnc id if the callbacks are set on a different choregrapher than the one they query for vsyncids. This cl tracks the callbacks and adds a trace point when a stale vsyncid is retrieved. Flag: EXEMPT logging Bug: 343039961 Test: perfetto traces Change-Id: Icbfd5a93267cd4c7e355f34bd544b436bcf8f2c7
-rw-r--r--core/java/android/view/Choreographer.java9
1 files changed, 9 insertions, 0 deletions
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index f0e673b3e3ac..7e247493e35c 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -41,6 +41,7 @@ import android.util.TimeUtils;
import android.view.animation.AnimationUtils;
import java.io.PrintWriter;
+import java.util.Locale;
/**
* Coordinates the timing of animations, input and drawing.
@@ -200,6 +201,7 @@ public final class Choreographer {
private final DisplayEventReceiver.VsyncEventData mLastVsyncEventData =
new DisplayEventReceiver.VsyncEventData();
private final FrameData mFrameData = new FrameData();
+ private volatile boolean mInDoFrameCallback = false;
/**
* Contains information about the current frame for jank-tracking,
@@ -818,6 +820,11 @@ public final class Choreographer {
* @hide
*/
public long getVsyncId() {
+ if (!mInDoFrameCallback && Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
+ String message = String.format(Locale.getDefault(), "unsync-vsync-id=%d isSfChoreo=%s",
+ mLastVsyncEventData.preferredFrameTimeline().vsyncId, this == getSfInstance());
+ Trace.instant(Trace.TRACE_TAG_VIEW, message);
+ }
return mLastVsyncEventData.preferredFrameTimeline().vsyncId;
}
@@ -853,6 +860,7 @@ public final class Choreographer {
if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) {
Trace.traceBegin(
Trace.TRACE_TAG_VIEW, "Choreographer#doFrame " + timeline.mVsyncId);
+ mInDoFrameCallback = true;
}
synchronized (mLock) {
if (!mFrameScheduled) {
@@ -947,6 +955,7 @@ public final class Choreographer {
doCallbacks(Choreographer.CALLBACK_COMMIT, frameIntervalNanos);
} finally {
AnimationUtils.unlockAnimationClock();
+ mInDoFrameCallback = false;
if (resynced) {
Trace.traceEnd(Trace.TRACE_TAG_VIEW);
}