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

Commit 974a5aa8 authored by Nicolò Mazzucato's avatar Nicolò Mazzucato
Browse files

Add tracing to FrameTracker

This will help us understand why there are some lenghty cpu compute blocks from FrameTracker

Bug: 373193674
Change-Id: If286610bf1ba577603c9508785a64361b4687025
Test: perfetto trace
Flag: NONE - adding logs
parent 4fbece52
Loading
Loading
Loading
Loading
+55 −35
Original line number Diff line number Diff line
@@ -252,6 +252,7 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
            mSurfaceChangedCallback = new ViewRootImpl.SurfaceChangedCallback() {
                @Override
                public void surfaceCreated(SurfaceControl.Transaction t) {
                    Trace.beginSection("FrameTracker#surfaceCreated");
                    mHandler.runWithScissors(() -> {
                        if (mSurfaceControl == null) {
                            mSurfaceControl = mViewRoot.getSurfaceControl();
@@ -261,6 +262,7 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                            }
                        }
                    }, EXECUTOR_TASK_TIMEOUT);
                    Trace.endSection();
                }

                @Override
@@ -462,6 +464,8 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
    @Override
    public void onJankDataAvailable(SurfaceControl.JankData[] jankData) {
        postCallback(() -> {
            try {
                Trace.beginSection("FrameTracker#onJankDataAvailable");
                if (mCancelled || mMetricsFinalized) {
                    return;
                }
@@ -479,6 +483,9 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                    }
                }
                processJankInfos();
            } finally {
                Trace.endSection();
            }
        });
    }

@@ -505,6 +512,8 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
    @Override
    public void onFrameMetricsAvailable(int dropCountSinceLastInvocation) {
        postCallback(() -> {
            try {
                Trace.beginSection("FrameTracker#onFrameMetricsAvailable");
                if (mCancelled || mMetricsFinalized) {
                    return;
                }
@@ -513,7 +522,8 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                // We should keep tracking the begin / end timestamp that we can compare with
                // vsync timestamp to check if the frame is in the duration of the CUJ.
                long totalDurationNanos = mMetricsWrapper.getMetric(FrameMetrics.TOTAL_DURATION);
            boolean isFirstFrame = mMetricsWrapper.getMetric(FrameMetrics.FIRST_DRAW_FRAME) == 1;
                boolean isFirstFrame =
                    mMetricsWrapper.getMetric(FrameMetrics.FIRST_DRAW_FRAME) == 1;
                long frameVsyncId =
                        mMetricsWrapper.getTiming()[FrameMetrics.Index.FRAME_TIMELINE_VSYNC_ID];

@@ -528,6 +538,9 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                            frameVsyncId, totalDurationNanos, isFirstFrame));
                }
                processJankInfos();
            } finally {
                Trace.endSection();
            }
        });
    }

@@ -573,6 +586,13 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai

    @UiThread
    private void finish() {
        Trace.beginSection("FrameTracker#finish");
        finishTraced();
        Trace.endSection();
    }

    @UiThread
    private void finishTraced() {
        if (mMetricsFinalized || mCancelled) return;
        mMetricsFinalized = true;