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

Commit 15b6d1e6 authored by Riddle Hsu's avatar Riddle Hsu Committed by Android (Google) Code Review
Browse files

Merge "Clean unnecessary lock of WindowAnimator#animate" into rvc-dev

parents 202e3811 ccfbcb81
Loading
Loading
Loading
Loading
+69 −85
Original line number Diff line number Diff line
@@ -96,8 +96,8 @@ public class WindowAnimator {
        mAnimationFrameCallback = frameTimeNs -> {
            synchronized (mService.mGlobalLock) {
                mAnimationFrameCallbackScheduled = false;
            }
                animate(frameTimeNs);
            }
        };
    }

@@ -115,23 +115,14 @@ public class WindowAnimator {
        mInitialized = true;
    }

    /**
     * DO NOT HOLD THE WINDOW MANAGER LOCK WHILE CALLING THIS METHOD. Reason: the method closes
     * an animation transaction, that might be blocking until the next sf-vsync, so we want to make
     * sure other threads can make progress if this happens.
     */
    private void animate(long frameTimeNs) {

        synchronized (mService.mGlobalLock) {
        if (!mInitialized) {
            return;
        }

            // Schedule next frame already such that back-pressure happens continuously
        // Schedule next frame already such that back-pressure happens continuously.
        scheduleAnimation();
        }

        synchronized (mService.mGlobalLock) {
        mCurrentTime = frameTimeNs / TimeUtils.NANOS_PER_MS;
        mBulkUpdateParams = SET_ORIENTATION_CHANGE_COMPLETE;
        if (DEBUG_WINDOW_TRACE) {
@@ -147,8 +138,8 @@ public class WindowAnimator {
            for (int i = 0; i < numDisplays; i++) {
                final int displayId = mDisplayContentsAnimators.keyAt(i);
                final DisplayContent dc = mService.mRoot.getDisplayContent(displayId);
                    // Update animations of all applications, including those
                    // associated with exiting/removed apps
                // Update animations of all applications, including those associated with
                // exiting/removed apps.
                dc.updateWindowsForAnimator();
                dc.prepareSurfaces();
            }
@@ -178,22 +169,16 @@ public class WindowAnimator {
            ProtoLog.i(WM_SHOW_TRANSACTIONS, "<<< CLOSE TRANSACTION animate");
        }

            boolean hasPendingLayoutChanges = mService.mRoot.hasPendingLayoutChanges(this);
            boolean doRequest = false;
            if (mBulkUpdateParams != 0) {
                doRequest = mService.mRoot.copyAnimToLayoutParams();
            }

        final boolean hasPendingLayoutChanges = mService.mRoot.hasPendingLayoutChanges(this);
        final boolean doRequest = mBulkUpdateParams != 0 && mService.mRoot.copyAnimToLayoutParams();
        if (hasPendingLayoutChanges || doRequest) {
            mService.mWindowPlacerLocked.requestTraversal();
        }

        final boolean rootAnimating = mService.mRoot.isAnimating(TRANSITION | CHILDREN);
        if (rootAnimating && !mLastRootAnimating) {

                // Usually app transitions but quite a load onto the system already (with all the
                // things happening in app), so pause task snapshot persisting to not increase the
                // load.
            // Usually app transitions but quite a load onto the system already (with all the things
            // happening in app), so pause task snapshot persisting to not increase the load.
            mService.mTaskSnapshotController.setPersisterPaused(true);
            Trace.asyncTraceBegin(Trace.TRACE_TAG_WINDOW_MANAGER, "animating", 0);
        }
@@ -220,7 +205,6 @@ public class WindowAnimator {
                    + " hasPendingLayoutChanges=" + hasPendingLayoutChanges);
        }
    }
    }

    private static String bulkUpdateParamsToString(int bulkUpdateParams) {
        StringBuilder builder = new StringBuilder(128);
+3 −7
Original line number Diff line number Diff line
@@ -1007,9 +1007,7 @@ public class WindowManagerService extends IWindowManager.Stub
    void openSurfaceTransaction() {
        try {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "openSurfaceTransaction");
            synchronized (mGlobalLock) {
            SurfaceControl.openTransaction();
            }
        } finally {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
@@ -1022,10 +1020,8 @@ public class WindowManagerService extends IWindowManager.Stub
    void closeSurfaceTransaction(String where) {
        try {
            Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "closeSurfaceTransaction");
            synchronized (mGlobalLock) {
            SurfaceControl.closeTransaction();
            mWindowTracing.logState(where);
            }
        } finally {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }