From 535ecc525e2dde740170642b0fc689b14d3cbb75 Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Fri, 4 Apr 2025 11:25:04 -0700 Subject: [PATCH] [Memory Leak] Fix leak of KeyboardQuickSwitchView and TaskbarOverlayDragLayer by SlideInRemoteTransition By the time SlideInRemoteTransition is started, KeyboardQuickSwitchView is already detached from window, causing 1. Rejection from InteractionJankMonitor to mointor jank 2. Leak of KeyboardQuickSwitchView and its parent view TaskbarOverlayDragLayer We should simply remove jank-monitoring of CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH as it's doing no-op and causing leak Fix: 407032864 Test: manual - verify leak fixed locally Flag: NONE - released code Change-Id: I8562d8da1c4f0ec1b88e7ffa8bbb8da75ee57548 --- .../KeyboardQuickSwitchViewController.java | 12 ++---------- .../taskbar/TaskbarActivityContext.java | 19 +------------------ .../quickstep/util/SlideInRemoteTransition.kt | 6 +----- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index 5add5c1a44..36317e358e 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -254,19 +254,13 @@ public class KeyboardQuickSwitchViewController { // first hidden non-desktop task view in recents view return mOnDesktop ? 1 : (mWasDesktopTaskFilteredOut ? index + 1 : index); } - Runnable onStartCallback = () -> InteractionJankMonitorWrapper.begin( - mKeyboardQuickSwitchView, Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH); - Runnable onFinishCallback = () -> InteractionJankMonitorWrapper.end( - Cuj.CUJ_LAUNCHER_KEYBOARD_QUICK_SWITCH_APP_LAUNCH); TaskbarActivityContext context = mControllers.taskbarActivityContext; final RemoteTransition slideInTransition = new RemoteTransition(new SlideInRemoteTransition( Utilities.isRtl(mControllers.taskbarActivityContext.getResources()), context.getDeviceProfile().overviewPageSpacing, QuickStepContract.getWindowCornerRadius(context), AnimationUtils.loadInterpolator( - context, android.R.interpolator.fast_out_extra_slow_in), - onStartCallback, - onFinishCallback), + context, android.R.interpolator.fast_out_extra_slow_in)), "SlideInTransition"); SystemUiProxy systemUiProxy = SystemUiProxy.INSTANCE.get( mKeyboardQuickSwitchView.getContext()); @@ -306,9 +300,7 @@ public class KeyboardQuickSwitchViewController { task, remoteTransition, mOnDesktop, - DesktopTaskToFrontReason.ALT_TAB, - onStartCallback, - onFinishCallback); + DesktopTaskToFrontReason.ALT_TAB); return -1; } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java index 88f5dd6f44..0988aec0c4 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java @@ -1635,15 +1635,6 @@ public class TaskbarActivityContext extends BaseTaskbarContext { } } - public void handleGroupTaskLaunch( - GroupTask task, - @Nullable RemoteTransition remoteTransition, - boolean onDesktop, - DesktopTaskToFrontReason toFrontReason) { - handleGroupTaskLaunch(task, remoteTransition, onDesktop, toFrontReason, - /* onStartCallback= */ null, /* onFinishCallback= */ null); - } - /** * Launches the given GroupTask with the following behavior: * - If the GroupTask is a DesktopTask, launch the tasks in that Desktop. @@ -1659,9 +1650,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext { GroupTask task, @Nullable RemoteTransition remoteTransition, boolean onDesktop, - DesktopTaskToFrontReason toFrontReason, - @Nullable Runnable onStartCallback, - @Nullable Runnable onFinishCallback) { + DesktopTaskToFrontReason toFrontReason) { if (task instanceof DesktopTask) { UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(this).showDesktopApps(getDisplay().getDisplayId(), @@ -1671,14 +1660,8 @@ public class TaskbarActivityContext extends BaseTaskbarContext { if (onDesktop && task instanceof SingleTask singleTask) { boolean useRemoteTransition = canUnminimizeDesktopTask(singleTask.getTask().key.id); UI_HELPER_EXECUTOR.execute(() -> { - if (onStartCallback != null) { - onStartCallback.run(); - } SystemUiProxy.INSTANCE.get(this).showDesktopApp(singleTask.getTask().key.id, useRemoteTransition ? remoteTransition : null, toFrontReason); - if (onFinishCallback != null) { - onFinishCallback.run(); - } }); return; } diff --git a/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt b/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt index ece958395f..15f59e425f 100644 --- a/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt +++ b/quickstep/src/com/android/quickstep/util/SlideInRemoteTransition.kt @@ -36,8 +36,6 @@ class SlideInRemoteTransition( private val pageSpacing: Int, private val cornerRadius: Float, private val interpolator: TimeInterpolator, - private val onStartCallback: Runnable, - private val onFinishCallback: Runnable, ) : RemoteTransitionStub() { private val animationDurationMs = 500L @@ -45,7 +43,7 @@ class SlideInRemoteTransition( transition: IBinder, info: TransitionInfo, startT: Transaction, - finishCB: IRemoteTransitionFinishedCallback + finishCB: IRemoteTransitionFinishedCallback, ) { val anim = ValueAnimator.ofFloat(0f, 1f) anim.interpolator = interpolator @@ -70,7 +68,6 @@ class SlideInRemoteTransition( startT.setCrop(leash, chg.endAbsBounds).setCornerRadius(leash, cornerRadius) } } - onStartCallback.run() startT.apply() anim.addUpdateListener { @@ -100,7 +97,6 @@ class SlideInRemoteTransition( val t = Transaction() try { finishCB.onTransitionFinished(null, t) - onFinishCallback.run() } catch (e: RemoteException) { // Ignore }