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

Commit e9ff4606 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Actually do not hold WM lock while closing transaction

Test: go/wm-smoke
Test: Quick switch 100x, observe no delay
Change-Id: I46022a23f749c52ba7f46e105679d728277970bd
Fixes: 62444483
parent 4eb76b2d
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -227,7 +227,10 @@ public class WindowAnimator {
            Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
        } finally {
            if (transactionOpen) {
                mService.closeSurfaceTransaction();

                // Do not hold window manager lock while closing the transaction, as this might be
                // blocking until the next frame, which can lead to total lock starvation.
                mService.closeSurfaceTransaction(false /* withLockHeld */);
                if (SHOW_TRANSACTIONS) Slog.i(TAG, "<<< CLOSE TRANSACTION animate");
            }
        }
+16 −0
Original line number Diff line number Diff line
@@ -891,10 +891,26 @@ public class WindowManagerService extends IWindowManager.Stub
    }

    void closeSurfaceTransaction() {
        closeSurfaceTransaction(true /* withLockHeld */);
    }

    /**
     * Closes a surface transaction.
     *
     * @param withLockHeld Whether to acquire the window manager while doing so. In some cases
     *                     holding the lock my lead to starvation in WM in case closeTransaction
     *                     blocks and we call it repeatedly, like we do for animations.
     */
    void closeSurfaceTransaction(boolean withLockHeld) {
        synchronized (mWindowMap) {
            if (mRoot.mSurfaceTraceEnabled) {
                mRoot.mRemoteEventTrace.closeSurfaceTransaction();
            }
            if (withLockHeld) {
                SurfaceControl.closeTransaction();
            }
        }
        if (!withLockHeld) {
            SurfaceControl.closeTransaction();
        }
    }