diff options
author | 2018-02-23 17:42:39 +0100 | |
---|---|---|
committer | 2018-02-23 17:51:40 +0100 | |
commit | 067b5bf19be1e07dd3310dfbb0a449eb329a54c5 (patch) | |
tree | a4d37b3e33dd1505f0f50be4a2b7e68f2131e6a8 | |
parent | e06975dd271a98b85fc63315211f6321b1119aee (diff) |
Fix ANR for real
Imagine the following sequence:
- Activity is requested to to be visible.
- Activity draws, app transition starts.
- Activity is requested to be invisible, but transition is still
pending because of another opening activity that hasn't drawn yet.
hiddenRequested=true
- First app transition finishes. clientHidden=true at the end of
the transition because hiddenRequested==true
- Activity is requested to be visible again. However, hidden==false
since we haven't started the new transition yet.
But then BOOOOM clientHidden is stuck at true and we ANR because
we never make the window visible again.
Fix this by uncoditionally setting client visibility when changing
app visibility.
Test:
adb shell monkey -p com.google.android.deskclock -p com.android.calculator -p com.android.calculator2 -p com.google.android.contacts -p com.android.launcher -p com.google.android.launcher -p com.android.mms -p com.google.android.apps.messaging -p com.android.phone -p com.google.android.dialer -p com.android.providers.downloads.ui -p com.android.settings -p com.google.android.calendar -p com.google.android.GoogleCamera -p com.google.android.apps.photos -p com.google.android.gms -p com.google.android.setupwizard -p com.google.android.googlequicksearchbox -p com.google.android.packageinstaller -p com.google.android.apps.nexuslauncher -c android.intent.category.LAUNCHER --ignore-security-exceptions --monitor-native-crashes -s 814 -v -v -v 125000
Change-Id: I40160266a465cb5a1a9c2ac6476d89e2829a537e
Fixes: 72160186
-rw-r--r-- | services/core/java/com/android/server/wm/AppWindowContainerController.java | 15 | ||||
-rw-r--r-- | services/core/java/com/android/server/wm/AppWindowToken.java | 2 |
2 files changed, 9 insertions, 8 deletions
diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java index e9efd4ec9e3d..40f772aaa529 100644 --- a/services/core/java/com/android/server/wm/AppWindowContainerController.java +++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java @@ -367,15 +367,14 @@ public class AppWindowContainerController if (wtoken.isHidden()) { wtoken.waitingToShow = true; } - - if (wtoken.isClientHidden()) { - // In the case where we are making an app visible but holding off for a - // transition, we still need to tell the client to make its windows visible - // so they get drawn. Otherwise, we will wait on performing the transition - // until all windows have been drawn, they never will be, and we are sad. - wtoken.setClientHidden(false); - } } + + // In the case where we are making an app visible but holding off for a transition, + // we still need to tell the client to make its windows visible so they get drawn. + // Otherwise, we will wait on performing the transition until all windows have been + // drawn, they never will be, and we are sad. + wtoken.setClientHidden(false); + wtoken.requestUpdateWallpaperIfNeeded(); if (DEBUG_ADD_REMOVE) Slog.v(TAG_WM, "No longer Stopped: " + wtoken); diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index 42d6ec090838..277a04b6b201 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -367,6 +367,8 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree if (mClientHidden == hideClient || (hideClient && mDeferHidingClient)) { return; } + if (DEBUG_APP_TRANSITIONS) Slog.v(TAG_WM, "setClientHidden: " + this + + " clientHidden=" + hideClient + " Callers=" + Debug.getCallers(5)); mClientHidden = hideClient; sendAppVisibilityToClients(); } |