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

Commit 8200cd37 authored by Wu Ahan's avatar Wu Ahan Committed by Automerger Merge Worker
Browse files

Merge "Mark instrument events of FrameTracker in the trace" into tm-dev am: 332cf2b6

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

Change-Id: I7e4c1d0b0091309420db5c4ca0ffcf1b0af704a1
parents 886d1cfc 332cf2b6
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.annotation.Nullable;
import android.graphics.HardwareRendererObserver;
import android.os.Handler;
import android.os.Trace;
import android.text.TextUtils;
import android.util.Log;
import android.util.SparseArray;
import android.view.Choreographer;
@@ -188,6 +189,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
                            if (mBeginVsyncId != INVALID_ID) {
                                mSurfaceControlWrapper.addJankStatsListener(
                                        FrameTracker.this, mSurfaceControl);
                                markEvent("FT#deferMonitoring");
                                postTraceStartMarker();
                            }
                        }
@@ -241,8 +243,9 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
            }
            if (mSurfaceControl != null) {
                if (mDeferMonitoring) {
                    markEvent("FT#deferMonitoring");
                    // Normal case, we begin the instrument from the very beginning,
                    // except the first frame.
                    // will exclude the first frame.
                    postTraceStartMarker();
                } else {
                    // If we don't begin the instrument from the very beginning,
@@ -272,6 +275,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
                return;
            }
            mTracingStarted = true;
            markEvent("FT#begin");
            Trace.beginAsyncSection(mSession.getName(), (int) mBeginVsyncId);
        }
    }
@@ -295,6 +299,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
                    Log.d(TAG, "end: " + mSession.getName()
                            + ", end=" + mEndVsyncId + ", reason=" + reason);
                }
                markEvent("FT#end#" + reason);
                Trace.endAsyncSection(mSession.getName(), (int) mBeginVsyncId);
                mSession.setReason(reason);

@@ -322,6 +327,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
                    reason == REASON_CANCEL_NOT_BEGUN || reason == REASON_CANCEL_SAME_VSYNC;
            if (mCancelled || (mEndVsyncId != INVALID_ID && !cancelFromEnd)) return false;
            mCancelled = true;
            markEvent("FT#cancel#" + reason);
            // We don't need to end the trace section if it never begun.
            if (mTracingStarted) {
                Trace.endAsyncSection(mSession.getName(), (int) mBeginVsyncId);
@@ -343,6 +349,11 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
        }
    }

    private void markEvent(String desc) {
        Trace.beginSection(TextUtils.formatSimple("%s#%s", mSession.getName(), desc));
        Trace.endSection();
    }

    private void notifyCujEvent(String action) {
        if (mListener == null) return;
        mListener.onCujEvents(mSession, action);