Skip to content

Commit cef37fb

Browse files
committed
Fix a bug where surface crashes when the enter animation starts while the exit animation has not yet finished
Bug: 5446482 Change-Id: I2e9f2e91ab5e8b22896d12e08fac76c72c997274
1 parent be25d5b commit cef37fb

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

services/java/com/android/server/wm/WindowManagerService.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2578,11 +2578,7 @@ public int relayoutWindow(Session session, IWindow client, int seq,
25782578
(win.mAppToken == null || !win.mAppToken.clientHidden)) {
25792579
displayed = !win.isVisibleLw();
25802580
if (win.mExiting) {
2581-
win.mExiting = false;
2582-
if (win.mAnimation != null) {
2583-
win.mAnimation.cancel();
2584-
win.mAnimation = null;
2585-
}
2581+
win.cancelExitAnimationForNextAnimationLocked();
25862582
}
25872583
if (win.mDestroying) {
25882584
win.mDestroying = false;

services/java/com/android/server/wm/WindowState.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,18 @@ public void clearAnimation() {
596596
}
597597
}
598598

599+
// TODO: Fix and call finishExit() instead of cancelExitAnimationForNextAnimationLocked()
600+
// for avoiding the code duplication.
601+
void cancelExitAnimationForNextAnimationLocked() {
602+
if (!mExiting) return;
603+
if (mAnimation != null) {
604+
mAnimation.cancel();
605+
mAnimation = null;
606+
destroySurfaceLocked();
607+
}
608+
mExiting = false;
609+
}
610+
599611
Surface createSurfaceLocked() {
600612
if (mSurface == null) {
601613
mReportDestroySurface = false;
@@ -1742,4 +1754,4 @@ public String toString() {
17421754
}
17431755
return mStringNameCache;
17441756
}
1745-
}
1757+
}

0 commit comments

Comments
 (0)