From b824f87c65216e4dfe5e9ab0e63795466836bc0f Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Wed, 30 May 2018 17:32:51 +0200 Subject: [PATCH] Defer stop for all activities becoming invisible If we are deferring a stop until a window is becoming visible, it's a good idea to also defer stopping all other activities that are go into stopping state to avoid flickers. This fixes an issue with quickstep when swiping right and the previous activity hasn't finished pausing yet when we start the new activity. In the normal case, prev=Launcher and all is fine, as we wait with stopping launcher until the animation is done. In the bad case, prev=the previous activity that was on screen before swiping, so Launcher doesn't get added to the waiting list, which means that it will be stopped too early, aborting the animation because Launcher is also driving it. Test: go/wm-smoke Test: Swipe right from Chrome to any other app, observe no jump Bug: 80313326 Change-Id: Ia24b5de74a1d321f11735cdffc331d3806bae2d8 --- .../core/java/com/android/server/am/ActivityStack.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index aaa51615bbb9a..11d2bb57bf47d 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -1652,6 +1652,13 @@ class ActivityStack extends ConfigurationContai void addToStopping(ActivityRecord r, boolean scheduleIdle, boolean idleDelayed) { if (!mStackSupervisor.mStoppingActivities.contains(r)) { mStackSupervisor.mStoppingActivities.add(r); + + // Some activity is waiting for another activity to become visible before it's being + // stopped, which means that we also want to wait with stopping this one to avoid + // flickers. + if (!mStackSupervisor.mActivitiesWaitingForVisibleActivity.isEmpty()) { + mStackSupervisor.mActivitiesWaitingForVisibleActivity.add(r); + } } // If we already have a few activities waiting to stop, then give up