Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 045230a4 authored by Charles Chen's avatar Charles Chen
Browse files

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
parent 5d3166d4
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -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");
        });
    }
}