From 53baa13515cc00fb8a65282878950ebfe6755a3a Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 10 Jun 2022 15:43:14 +0800 Subject: Fixes a race condition when merge animation transition When merge a TO_FRONT transition to the recents animation, onTasksAppeared will finish the recents animation, so there can be a race that the open transition for recents animation might be finish before the merge transition, which leave the merge transition become a standalone transition. To make the sequence correct, register a transition commit callback to know the merge transition has done in Shell, then goes to finish the recents animation. Bug: 235433368 Test: enable shell transitin, quick switch back/forward and verify no flicker. Change-Id: I39fc898a8922f900e1e1808f92a471749664e194 --- .../systemui/shared/system/RemoteTransitionCompat.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java index e9ac26182c7e..db416013c453 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteTransitionCompat.java @@ -186,6 +186,8 @@ public class RemoteTransitionCompat implements Parcelable { } catch (RemoteException e) { Log.e(TAG, "Error merging transition.", e); } + // commit taskAppeared after merge transition finished. + mRecentsSession.commitTasksAppearedIfNeeded(recents); } }; mTransition = new RemoteTransition(remote, appThread); @@ -226,6 +228,7 @@ public class RemoteTransitionCompat implements Parcelable { private PictureInPictureSurfaceTransaction mPipTransaction = null; private IBinder mTransition = null; private boolean mKeyguardLocked = false; + private RemoteAnimationTargetCompat[] mAppearedTargets; void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info, IRemoteTransitionFinishedCallback finishCB, @@ -251,6 +254,7 @@ public class RemoteTransitionCompat implements Parcelable { boolean merge(TransitionInfo info, SurfaceControl.Transaction t, RecentsAnimationListener recents) { SparseArray openingTasks = null; + mAppearedTargets = null; boolean cancelRecents = false; boolean homeGoingAway = false; boolean hasChangingApp = false; @@ -331,10 +335,17 @@ public class RemoteTransitionCompat implements Parcelable { targets[i] = target; } t.apply(); - recents.onTasksAppeared(targets); + mAppearedTargets = targets; return true; } + private void commitTasksAppearedIfNeeded(RecentsAnimationListener recents) { + if (mAppearedTargets != null) { + recents.onTasksAppeared(mAppearedTargets); + mAppearedTargets = null; + } + } + @Override public ThumbnailData screenshotTask(int taskId) { try { final TaskSnapshot snapshot = -- cgit v1.2.3-59-g8ed1b