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

Commit c6a75a8d authored by Jorim Jaggi's avatar Jorim Jaggi Committed by android-build-merger
Browse files

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

Merge "Actually do not hold WM lock while closing transaction" into oc-dev am: 7831f0c4 am: 06f3e97e
am: b8fe4339

Change-Id: I368f1c4158e1a7b209fea067a27930f0723d1c95
parents b2ad432d b8fe4339
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
@@ -896,10 +896,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();
        }
    }