From 8209517c2c4f7b1fc36687b81fed42e5f0d7f556 Mon Sep 17 00:00:00 2001 From: Luca Zuccarini Date: Fri, 27 Oct 2023 12:24:08 +0000 Subject: [PATCH] Revert "Reuse the main depth controller for launch animations." This reverts commit ff2b38e3668f82fc7db2fddf193b72a22b1a37bf. Reason for revert: Caused jank regressions: b/307779813, b/307766171. Change-Id: I3d513196f9fd8f0768affdda73c0ab8924790037 --- .../launcher3/QuickstepTransitionManager.java | 9 ++++++--- .../launcher3/statehandlers/DepthController.java | 12 ++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index 4bee82af8c..cca0fd4e47 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -1061,9 +1061,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean allowBlurringLauncher = mLauncher.getStateManager().getState() != OVERVIEW && BlurUtils.supportsBlursOnWindows(); - ObjectAnimator backgroundRadiusAnim = - ObjectAnimator.ofFloat(mLauncher.getDepthController().stateDepth, - MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) + LaunchDepthController depthController = new LaunchDepthController(mLauncher); + ObjectAnimator backgroundRadiusAnim = ObjectAnimator.ofFloat(depthController.stateDepth, + MULTI_PROPERTY_VALUE, BACKGROUND_APP.getDepth(mLauncher)) .setDuration(APP_LAUNCH_DURATION); if (allowBlurringLauncher) { @@ -1089,6 +1089,9 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener new SurfaceControl.Transaction().remove(dimLayer).apply())); } + backgroundRadiusAnim.addListener( + AnimatorListeners.forEndCallback(depthController::dispose)); + return backgroundRadiusAnim; } diff --git a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java index 957db6414e..882682dc4a 100644 --- a/quickstep/src/com/android/launcher3/statehandlers/DepthController.java +++ b/quickstep/src/com/android/launcher3/statehandlers/DepthController.java @@ -94,6 +94,18 @@ public class DepthController extends BaseDepthController implements StateHandler } } + /** + * Cleans up after this controller so it can be garbage collected without leaving traces. + */ + public void dispose() { + removeSecondaryListeners(); + + if (mLauncher.getRootView() != null && mOnAttachListener != null) { + mLauncher.getRootView().removeOnAttachStateChangeListener(mOnAttachListener); + mOnAttachListener = null; + } + } + private void removeSecondaryListeners() { if (mCrossWindowBlurListener != null) { CrossWindowBlurListeners.getInstance().removeListener(mCrossWindowBlurListener);