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

Commit 72911a41 authored by Pascal Mütschard's avatar Pascal Mütschard
Browse files

Fix missing jank data for destroyed SurfaceControls.

Changes the FrameTracker to go through the standard waiting-for-jank-
data finish process, when a SurfaceControl is destroyed, instead of the
current process of finishing the CUJ immediatly, as that usually happens
before any jank data is received, or at least not for the last N frames.

Request jank data flushes, even if the SurfaceControl has been destroyed
on the client side, as long as the layer still exists in the composer.

Fixes the max frame duration, when not using HWUI callbacks.

Bug: b/392849939
Test: manual, SysUI perf tests
Flag: EXEMPT bugfix
Change-Id: Ica9695fb04dbb241ed1d24ff693fb24d162434c5
parent 24109ce0
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -257,15 +257,11 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai

                @Override
                public void surfaceDestroyed() {

                    // Wait a while to give the system a chance for the remaining
                    // frames to arrive, then force finish the session.
                    mHandler.postDelayed(() -> {
                    mHandler.post(() -> {
                        if (!mMetricsFinalized) {
                            end(REASON_END_SURFACE_DESTROYED);
                            finish();
                        }
                    }, 50);
                    });
                }
            };
            // This callback has a reference to FrameTracker,
@@ -367,10 +363,10 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                    // Send a flush jank data transaction.
                    if (mSurfaceControl != null && mSurfaceControl.isValid()) {
                        SurfaceControl.Transaction.sendSurfaceFlushJankData(mSurfaceControl);
                    }
                    if (mJankDataListenerRegistration != null) {
                        mJankDataListenerRegistration.flush();
                    }
                    }

                    long delay;
                    if (mFlushAttempts < MAX_FLUSH_ATTEMPTS) {
@@ -650,6 +646,8 @@ public class FrameTracker implements HardwareRendererObserver.OnFrameMetricsAvai
                    Log.w(TAG, "Missing SF jank callback for vsyncId: " + info.frameVsyncId
                            + ", CUJ=" + name);
                }
            } else if (Flags.useSfFrameDuration() && info.surfaceControlCallbackFired) {
                maxFrameTimeNanos = Math.max(info.totalDurationNanos, maxFrameTimeNanos);
            }
        }
        maxSuccessiveMissedFramesCount = Math.max(