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

Commit b68521d9 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Fix misclassified jank for CUJ SHADE_DIALOG_OPEN (and others).

This fix includes two changes:
1. The jank should be measured in and attributed to the opening
   dialog's window, not the origin view's window. This is because
   that's where the animation actually happens.
2. Logging should begin when the animator starts, and not when the
   animation is requested to start, because these two do not happen
   in the same frame.

Bug: 409008342
Flag: com.android.systemui.fix_dialog_launch_animation_jank_logging
Test: atest DialogTransitionAnimatorTest + perfetto
Change-Id: Ia8d338217e2441d3aba0e5b922fb4d1878612cf4
parent ad6bb95f
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -2048,3 +2048,13 @@ flag {
     purpose: PURPOSE_BUGFIX
   }
}

flag {
    name: "fix_dialog_launch_animation_jank_logging"
    namespace: "systemui"
    description: "Adjust timing of jank logging for dialog launch animations, and attach it to the dialog window instead of the origin view window."
    bug: "409008342"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+22 −9
Original line number Diff line number Diff line
@@ -151,6 +151,7 @@ constructor(
         * controlled by this controller.
         */
        // TODO(b/252723237): Make this non-nullable
        @Deprecated("Jank should be measured in the dialog's window, not the origin view's")
        fun jankConfigurationBuilder(): InteractionJankMonitor.Configuration.Builder?

        companion object {
@@ -576,6 +577,7 @@ private class AnimatedDialog(
    private var hasInstrumentedJank = false

    fun start() {
        if (!Flags.fixDialogLaunchAnimationJankLogging()) {
            val cuj = controller.cuj
            if (cuj != null) {
                val config = controller.jankConfigurationBuilder()
@@ -588,6 +590,7 @@ private class AnimatedDialog(
                    hasInstrumentedJank = true
                }
            }
        }

        // Create the dialog so that its onCreate() method is called, which usually sets the dialog
        // content.
@@ -784,6 +787,16 @@ private class AnimatedDialog(
            return
        }

        if (Flags.fixDialogLaunchAnimationJankLogging()) {
            controller.cuj?.let { cuj ->
                val config =
                    InteractionJankMonitor.Configuration.Builder.withView(cuj.cujType, decorView)
                if (cuj.tag != null) config.setTag(cuj.tag)
                interactionJankMonitor.begin(config)
                hasInstrumentedJank = true
            }
        }

        // Show the background dim.
        dialog.window?.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)