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
This commit is contained in:
Charles Chen
2021-03-04 17:59:46 +08:00
parent 5d3166d403
commit 045230a432

View File

@@ -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");
});
}
}