From 79885f4c88f58ef3341081b78ace5b76f1214a8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Wed, 29 Mar 2023 02:49:04 +0000 Subject: [PATCH] Fix a stale animator reference being used on bounds change The call to setDestinationBounds applies the shadow if animation type is alpha and it's called on each keep clear area change event, when sometimes the enter PiP animation has not started yet (hence there is a stale reference to old animator that should have been cleaned up in onTaskVanished). Bug: 275646078 Test: before http://recall/-/ekEuGtt9d9HWqkUtAzpHx8/dXniGevCFIEI5nyLN0zw1V but only if the .isRuning condition is removed from updateAnimatorBounds Test: after http://recall/-/ekEuGtt9d9HWqkUtAzpHx8/c3FwTxsPWiRT67JjxcWrMw Change-Id: I34cb5b7621bf7c087d9c6e5a736b240e01d18a6a --- .../src/com/android/wm/shell/pip/PipAnimationController.java | 5 +++++ .../Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java | 1 + 2 files changed, 6 insertions(+) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java index 4c53f607a5f83..f70df833cf4ff 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java @@ -188,6 +188,11 @@ public class PipAnimationController { return mCurrentAnimator; } + /** Reset animator state to prevent it from being used after its lifetime. */ + public void resetAnimatorState() { + mCurrentAnimator = null; + } + private PipTransitionAnimator setupPipTransitionAnimator(PipTransitionAnimator animator) { animator.setSurfaceTransactionHelper(mSurfaceTransactionHelper); animator.setInterpolator(Interpolators.FAST_OUT_SLOW_IN); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java index 984c3c1a4eb03..b28d8fc39585e 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipTaskOrganizer.java @@ -1823,6 +1823,7 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, animator::clearContentOverlay); } PipAnimationController.quietCancel(animator); + mPipAnimationController.resetAnimatorState(); } }