From b478e576adc3b77bbda23a63833d58bc450e44da Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Fri, 20 Mar 2020 11:07:17 -0700 Subject: [PATCH] Account for stopping activities when determining whether to restart - We were seeing a flakey issue with gesture nav, when swiping immediately after launching an app, the system would stop launcher, but shortly after, we would start the recents animation for the next gesture. The recents animation calls: [RWC->DC->AS].ensureActivitiesVisible() -> EnsureActivitiesVisibleHelper.setActivityVisibilityState() -> AR.makeActiveIfNeeded() -> AR.shouldStartActivity() and the visible is requested, but we are currently still stopping because the client hasn't called back. This results in the animation continuing, but the system silently not scheduling launcher to be started, which prevents a draw-callback to finish on the client side, which then prevents us from finishing the recents animation (we are waiting for the draw to update the task view with the snapshot). Bug: 151788100 Test: Manual, it's hard to repro but you just have to swipe up after launching apps really quickly to get stuck in a state where you can't swipe up at all Change-Id: I32628f1e532764fc1ef962c6d4602214ca7c36c4 --- services/core/java/com/android/server/wm/ActivityRecord.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 6d53786ddf414..3477d82f4d718 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -4618,6 +4618,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } catch (Exception e) { Slog.w(TAG, "Exception thrown sending start: " + intent.getComponent(), e); } + // The activity may be waiting for stop, but that is no longer appropriate if we are + // starting the activity again + mStackSupervisor.mStoppingActivities.remove(this); } return false; } @@ -4667,7 +4670,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A * and {@link #shouldPauseActivity(ActivityRecord)}. */ private boolean shouldStartActivity() { - return mVisibleRequested && isState(STOPPED); + return mVisibleRequested && (isState(STOPPED) || isState(STOPPING)); } /**