From a338219a269f4f9a5fd648bf8113e1180ff4083a Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 18 Jul 2017 14:33:21 +0200 Subject: Fix threading issue with splash screens If we use a different thread to remove the view than we added it, it leads to suffering. WindowManagerGlobal.removeView ends up setting mParent of the DecorView to null, without any locking, which can lead to crashes. Test: Device boots, starting windows work. Otherwise: Pray Change-Id: Ifc1e0d0236746aef4ed2b63e08af7de695ce69aa Fixes: 63664477 --- .../java/com/android/server/wm/AppWindowContainerController.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/AppWindowContainerController.java b/services/core/java/com/android/server/wm/AppWindowContainerController.java index 86e130d723d8..a6ffe83c366e 100644 --- a/services/core/java/com/android/server/wm/AppWindowContainerController.java +++ b/services/core/java/com/android/server/wm/AppWindowContainerController.java @@ -685,7 +685,10 @@ public class AppWindowContainerController if (DEBUG_STARTING_WINDOW) Slog.v(TAG_WM, "Schedule remove starting " + mContainer + " startingWindow=" + mContainer.startingWindow); - mHandler.post(mRemoveStartingWindow); + + // Use the same thread to remove the window as we used to add it, as otherwise we end up + // with things in the view hierarchy being called from different threads. + mService.mAnimationHandler.post(mRemoveStartingWindow); } } -- cgit v1.2.3-59-g8ed1b