Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1a761a62 authored by Vishnu Nair's avatar Vishnu Nair
Browse files

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
parent 266b176e
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);
            }