summaryrefslogtreecommitdiff
path: root/core/java
diff options
context:
space:
mode:
authorCharles Chen <charlesccchen@google.com>2021-03-04 17:59:46 +0800
committerCharles Chen <charlesccchen@google.com>2021-03-09 21:39:38 +0800
commit045230a4329620eac05d439ecb96c0387a72b6a5 (patch)
treeb4c29866f072306f80c54789abbf34f678201c7e /core/java
parent5d3166d40316b7a2864f37a5098f3e9de7ed1021 (diff)
Fix deadlock between WMG and WMS
The dealock happened while WM#addView and WMS holds lock and called onWindowTokenRemoved. WM#addView -> WMG#addView(holds WMG lock) -> ... -> WMS#addWindow(holds WMS lock) (holds WMS lock) ... -> WindowTokenClient#onWindowTokenRemoved ... -> WMG#closeAll(holds WMG lock) This CL calls to WMG#closeAll asynchronously to release WMG lock fixes: 181839758 Test: manual Change-Id: I0cf8a505043a4def4dcf346952873b1362a92084
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/WindowTokenClient.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/core/java/android/app/WindowTokenClient.java b/core/java/android/app/WindowTokenClient.java
index 29792ac47a36..2298e84d755e 100644
--- a/core/java/android/app/WindowTokenClient.java
+++ b/core/java/android/app/WindowTokenClient.java
@@ -85,8 +85,10 @@ public class WindowTokenClient extends IWindowToken.Stub {
context.destroy();
mContextRef.clear();
}
- // If a secondary display is detached, release all views attached to this token.
- WindowManagerGlobal.getInstance().closeAll(this, mContextRef.getClass().getName(),
- "WindowContext");
+ ActivityThread.currentActivityThread().getHandler().post(() -> {
+ // If the tracked window token is detached, release all views attached to this token.
+ WindowManagerGlobal.getInstance().closeAll(WindowTokenClient.this,
+ "#onWindowTokenRemoved()", "WindowTokenClient");
+ });
}
}