From 0319e06c1fa97e1a513416a7bb627c438383e2e4 Mon Sep 17 00:00:00 2001 From: Li Li Date: Thu, 22 Sep 2022 01:29:50 -0700 Subject: [PATCH] Kill the app if it fails to set visibility If any window is out of sync in visibility, it's fine to kill. WM will catch the exception in resumeTopActivity() and restart it. Bug: 231624308 Test: drain async binder buffer and verify WM kills and restarts app. Change-Id: Id382f92da946a68ec0b1548a0597bed5602c49fa --- services/core/java/com/android/server/wm/WindowState.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index fd18d3de180e4..18ddaec812708 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3468,7 +3468,13 @@ class WindowState extends WindowContainer implements WindowManagerP "Setting visibility of " + this + ": " + clientVisible); mClient.dispatchAppVisibility(clientVisible); } catch (RemoteException e) { + // The remote client fails to process the visibility message. That means it is in a + // wrong state. E.g. the binder buffer is running out or the binder threads are dead. + // The window visibility is out-of-sync that may cause blank content or left over, so + // just kill it. And if it is a window of foreground activity, the activity can be + // restarted automatically if needed. Slog.w(TAG, "Exception thrown during dispatchAppVisibility " + this, e); + android.os.Process.killProcess(mSession.mPid); } }