From 5e49e12bb2b64903ece280406f897247a9f6a548 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Fri, 14 May 2021 17:41:19 +0800 Subject: [PATCH] Fix ActivityRecord leak if mainWindow is animating. For CTS test, sometimes remove starting window won't pass throught WS#removeIfPossible if the binder was dead before reveal animation finish. For this case, cancel reveal animation in WS#removeIfPossible if it's animating reveal animation. Bug: 184830058 Bug: 188245125 Bug: 188244674 Test: verify from bugreport that no systemui crash after WM's CTS. Test: run atest StartActivityTests then verify no activity leaked. Change-Id: I81484870ff89a78b6133be03d439d45d550bdd8c --- .../java/com/android/server/wm/WindowState.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index b121bfc2aa7df..dd9e53e57face 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -2409,18 +2409,22 @@ class WindowState extends WindowContainer implements WindowManagerP final boolean startingWindow = mAttrs.type == TYPE_APPLICATION_STARTING; if (startingWindow) { ProtoLog.d(WM_DEBUG_STARTING_WINDOW, "Starting window removed %s", this); - } - - if (startingWindow && StartingSurfaceController.DEBUG_ENABLE_SHELL_DRAWER) { // Cancel the remove starting window animation on shell. The main window might changed // during animating, checking for all windows would be safer. if (mActivityRecord != null) { - mActivityRecord.forAllWindows(w -> { + mActivityRecord.forAllWindowsUnchecked(w -> { if (w.isSelfAnimating(0, ANIMATION_TYPE_STARTING_REVEAL)) { w.cancelAnimation(); + return true; } + return false; }, true); } + } else if (mAttrs.type == TYPE_BASE_APPLICATION + && isSelfAnimating(0, ANIMATION_TYPE_STARTING_REVEAL)) { + // Cancel the remove starting window animation in case the binder dead before remove + // splash window. + cancelAnimation(); } ProtoLog.v(WM_DEBUG_FOCUS, "Remove client=%x, surfaceController=%s Callers=%s", @@ -2428,7 +2432,6 @@ class WindowState extends WindowContainer implements WindowManagerP mWinAnimator.mSurfaceController, Debug.getCallers(5)); - final long origId = Binder.clearCallingIdentity(); try {