summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Siarhei Vishniakou <svv@google.com> 2025-01-06 18:34:35 -0800
committer Siarhei Vishniakou <svv@google.com> 2025-01-06 19:04:01 -0800
commita629d023d482c5a986031d29b45a5ccbeb68dce3 (patch)
treef4cf7ab68949228f9e6c067471cf83e5fac642b9
parentf492c93e40d43f23947eb0f01d7bee1d38425cc3 (diff)
Log the exception when the view couldn't get added
We are getting reports of a crash inside ViewRootImpl's InputStage.onDetachedFromWindow method, due to 'mFirstInputStage' object being null. The only way that could happen is if 'mAdded' is true, but an exception occurs sometime before 'mFirstInputStage' is assigned. The most likely caller of this location is WindowManagerGlobal. Inside WMG, there is a "try / catch" section. The actual exception is indeed getting rethrown. However, because it's java, it's hard to trace whether anyone else higher up is catching this exception. Therefore, simply null checking the mFirstInputStage might be just postponing this problem. If we are going to throw anyways, then it's likely that try / catch approach of WMG is not needed - we should just throw and not do the "removeViewLocked" code. In this CL, the proposal is to add a log of the exception as soon as it occurs, so that we can learn more about the problem. We can then make a more informed decision on how to handle it. Bug: 385705687 Flag: EXEMPT refactor Test: none Change-Id: I3d239bcd5b84710325d33fff86d99a4be9a8dc3f
-rw-r--r--core/java/android/view/WindowManagerGlobal.java1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/java/android/view/WindowManagerGlobal.java b/core/java/android/view/WindowManagerGlobal.java
index f50ea9106a61..25bd713d9191 100644
--- a/core/java/android/view/WindowManagerGlobal.java
+++ b/core/java/android/view/WindowManagerGlobal.java
@@ -453,6 +453,7 @@ public final class WindowManagerGlobal {
try {
root.setView(view, wparams, panelParentView, userId);
} catch (RuntimeException e) {
+ Log.e(TAG, "Couldn't add view: " + view, e);
final int viewIndex = (index >= 0) ? index : (mViews.size() - 1);
// BadTokenException or InvalidDisplayException, clean up.
if (viewIndex >= 0) {