From 6cfe2e6cbe52f5fc9aa0eb94afaeb7679810cc13 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 23 Jun 2023 18:14:00 +0000 Subject: [PATCH] Restore strong reference to animation runner - The remote animation factory needs to be strongly referenced since the only other reference is a weakly held one from LauncherAnimationRunner, and if a gc happens in between starting the animation and the onAnimationStart() callback, then the animation will not play. Fixes: 284106887 Test: Force a gc after creating a remote app launch animation and ensure that the runner still exists when the animation starts Change-Id: I5f584451b41c666916801b8ea0cb470c7ab9fc51 --- .../com/android/launcher3/QuickstepTransitionManager.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java index e5fd605904..33a9f48a82 100644 --- a/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java +++ b/quickstep/src/com/android/launcher3/QuickstepTransitionManager.java @@ -229,6 +229,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener private RemoteAnimationProvider mRemoteAnimationProvider; // Strong refs to runners which are cleared when the launcher activity is destroyed private RemoteAnimationFactory mWallpaperOpenRunner; + private RemoteAnimationFactory mAppLaunchRunner; private RemoteAnimationFactory mKeyguardGoingAwayRunner; private RemoteAnimationFactory mWallpaperOpenTransitionRunner; @@ -298,17 +299,17 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener boolean fromRecents = isLaunchingFromRecents(v, null /* targets */); RunnableList onEndCallback = new RunnableList(); - RemoteAnimationFactory delegateRunner = new AppLaunchAnimationRunner(v, onEndCallback); + mAppLaunchRunner = new AppLaunchAnimationRunner(v, onEndCallback); ItemInfo tag = (ItemInfo) v.getTag(); if (tag != null && tag.shouldUseBackgroundAnimation()) { ContainerAnimationRunner containerAnimationRunner = ContainerAnimationRunner.from(v, mStartingWindowListener, onEndCallback); if (containerAnimationRunner != null) { - delegateRunner = containerAnimationRunner; + mAppLaunchRunner = containerAnimationRunner; } } RemoteAnimationRunnerCompat runner = new LauncherAnimationRunner( - mHandler, delegateRunner, true /* startAtFrontOfQueue */); + mHandler, mAppLaunchRunner, true /* startAtFrontOfQueue */); // Note that this duration is a guess as we do not know if the animation will be a // recents launch or not for sure until we know the opening app targets. @@ -1164,6 +1165,7 @@ public class QuickstepTransitionManager implements OnDeviceProfileChangeListener // Also clear strong references to the runners registered with the remote animation // definition so we don't have to wait for the system gc mWallpaperOpenRunner = null; + mAppLaunchRunner = null; mKeyguardGoingAwayRunner = null; } }