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

Commit 7831f0c4 authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Actually do not hold WM lock while closing transaction" into oc-dev

parents d1094717 e9ff4606
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -228,7 +228,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
@@ -893,10 +893,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();
        }
    }