From e338982c973fc601ad9ca0746315048de6e525a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Ciche=C5=84ski?= Date: Fri, 16 Jun 2023 21:12:29 +0000 Subject: [PATCH] Reparent PiP overlay under task as soon as possible For enter PiP animations started from Launcher, we send the signal to WMShell to reparent the overlay under task as soon as possible. This avoids flicker issue caused by race condition of cleaning up the transition leash before the reparenting was done, which made the issue of overlay being not attached to anything for few frames. Bug: 281711939 Test: winscope trace from comment#28, leash follows task Test: after http://recall/-/ekEuGtt9d9HWqkUtAzpHx8/ewrarENSYYOmUCa0b3fdtp Change-Id: Ia16afd49a94d9ba8456287c2cdffb2a84e5a2bc7 Merged-In: Ia16afd49a94d9ba8456287c2cdffb2a84e5a2bc7 --- .../android/quickstep/AbsSwipeUpHandler.java | 19 ++++++++++++++----- .../com/android/quickstep/SystemUiProxy.java | 6 +++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 63f1336cca..43db7c380c 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -1515,6 +1515,20 @@ public abstract class AbsSwipeUpHandler, if (mSwipePipToHomeReleaseCheck != null) { mSwipePipToHomeReleaseCheck.setCanRelease(false); } + + // grab a screenshot before the PipContentOverlay gets parented on top of the task + UI_HELPER_EXECUTOR.execute(() -> { + mTaskSnapshot = mRecentsAnimationController.screenshotTask( + mGestureState.getRunningTaskId()); + }); + + // let SystemUi reparent the overlay leash as soon as possible + SystemUiProxy.INSTANCE.get(mContext).stopSwipePipToHome( + mSwipePipToHomeAnimator.getTaskId(), + mSwipePipToHomeAnimator.getComponentName(), + mSwipePipToHomeAnimator.getDestinationBounds(), + mSwipePipToHomeAnimator.getContentOverlay()); + windowAnim = mSwipePipToHomeAnimators; } else { mSwipePipToHomeAnimator = null; @@ -2089,11 +2103,6 @@ public abstract class AbsSwipeUpHandler, */ private void maybeFinishSwipePipToHome() { if (mIsSwipingPipToHome && mSwipePipToHomeAnimators[0] != null) { - SystemUiProxy.INSTANCE.get(mContext).stopSwipePipToHome( - mSwipePipToHomeAnimator.getTaskId(), - mSwipePipToHomeAnimator.getComponentName(), - mSwipePipToHomeAnimator.getDestinationBounds(), - mSwipePipToHomeAnimator.getContentOverlay()); mRecentsAnimationController.setFinishTaskTransaction( mSwipePipToHomeAnimator.getTaskId(), mSwipePipToHomeAnimator.getFinishTransaction(), diff --git a/quickstep/src/com/android/quickstep/SystemUiProxy.java b/quickstep/src/com/android/quickstep/SystemUiProxy.java index ba809514c8..9350c729ca 100644 --- a/quickstep/src/com/android/quickstep/SystemUiProxy.java +++ b/quickstep/src/com/android/quickstep/SystemUiProxy.java @@ -549,9 +549,9 @@ public class SystemUiProxy implements ISystemUiProxy { } /** - * Notifies WM Shell that launcher has finished all the animation for swipe to home. WM Shell - * can choose to fade out the overlay when entering PIP is finished, and WM Shell should be - * responsible for cleaning up the overlay. + * Notifies WM Shell that launcher has finished the preparation of the animation for swipe to + * home. WM Shell can choose to fade out the overlay when entering PIP is finished, and WM Shell + * should be responsible for cleaning up the overlay. */ public void stopSwipePipToHome(int taskId, ComponentName componentName, Rect destinationBounds, SurfaceControl overlay) {