From 129493d418189b574d455590933620ae929e5e67 Mon Sep 17 00:00:00 2001 From: "jorgegil@google.com" Date: Thu, 24 Jun 2021 15:55:38 -0700 Subject: [PATCH] Cancel ongoing PIP animations in onTaskVanished onTaskVanished may be called when an activity is moved to the back while a resize animation is still in progress. This causes a race between the windowing mode change to fullscreen and the PIP resize that results in the fullscreen task leash getting a PIP-sized crop. This change cancels any ongoing animations in onTaskVanished and makes sure that finishResize() is not called when the animation is canceled because the transition to fullscreen will handle the final resize and cropping. Bug: 188856244 Test: enter YT PIP, click the next button and the music button quickly after that, then re-open YT from the notification - verify the activity is fullscreen and is cropped correctly. Change-Id: Ide52b8c6b63205081bde96472a5e0589664e1c8a --- .../src/com/android/wm/shell/pip/PipTaskOrganizer.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 afd7d2694ad6a..b863168b03814 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 @@ -722,6 +722,14 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener, if (info.displayId != Display.DEFAULT_DISPLAY && mOnDisplayIdChangeCallback != null) { mOnDisplayIdChangeCallback.accept(Display.DEFAULT_DISPLAY); } + + final PipAnimationController.PipTransitionAnimator animator = + mPipAnimationController.getCurrentAnimator(); + if (animator != null) { + animator.removeAllUpdateListeners(); + animator.removeAllListeners(); + animator.cancel(); + } } @Override