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

Commit 82a9c311 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Automerger Merge Worker
Browse files

Merge "Only start tracing in the next frame" into sc-dev am: 469c53f2

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14294130

Change-Id: I969bd43cd592c96cc22c1953d8dd83542dd2404c
parents 79d5f47f 469c53f2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -102,6 +102,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
    private boolean mMetricsFinalized;
    private boolean mCancelled = false;
    private FrameTrackerListener mListener;
    private boolean mTracingStarted = false;

    private static class JankInfo {
        long frameVsyncId;
@@ -207,7 +208,15 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
    public synchronized void begin() {
        mBeginVsyncId = mChoreographer.getVsyncId() + 1;
        mSession.setTimeStamp(System.nanoTime());
        mChoreographer.mChoreographer.postCallback(Choreographer.CALLBACK_INPUT, () -> {
            synchronized (FrameTracker.this) {
                if (mCancelled || mEndVsyncId != INVALID_ID) {
                    return;
                }
                mTracingStarted = true;
                Trace.beginAsyncSection(mSession.getName(), (int) mBeginVsyncId);
            }
        }, null);
        mRendererWrapper.addObserver(mObserver);
        if (DEBUG) {
            Log.d(TAG, "begin: " + mSession.getName() + ", begin=" + mBeginVsyncId);
@@ -255,7 +264,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
     */
    public synchronized void cancel(@Reasons int reason) {
        // We don't need to end the trace section if it never begun.
        if (mBeginVsyncId != INVALID_ID) {
        if (mTracingStarted) {
            Trace.endAsyncSection(mSession.getName(), (int) mBeginVsyncId);
        }
        mCancelled = true;
+6 −0
Original line number Diff line number Diff line
@@ -79,6 +79,12 @@ import java.util.concurrent.TimeUnit;

/**
 * This class let users to begin and end the always on tracing mechanism.
 *
 * Enabling for local development:
 *
 * adb shell device_config put interaction_jank_monitor enabled true
 * adb shell device_config put interaction_jank_monitor sampling_interval 1
 *
 * @hide
 */
public class InteractionJankMonitor {