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

Commit 92c579be authored by Chavi Weingarten's avatar Chavi Weingarten
Browse files

Only apply pendingTransaction if hasPendingTransaction is true

The current code will attempt to apply pendingTransaction when a frame
didn't draw even if no one called applyTransactionOnDraw.

Add a check if mHasPendingTransaction to make sure we don't overapply.

Test: Build
Bug: 302404882
Change-Id: I2b5781d53586ec37df88d79d3ccaa680263ec941
parent c7170612
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -3879,8 +3879,8 @@ public final class ViewRootImpl implements ViewParent,
                mPendingTransitions.clear();
            }

            handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mPendingTransaction,
                    "view not visible");
            handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mHasPendingTransactions,
                    mPendingTransaction, "view not visible");
        } else if (cancelAndRedraw) {
            mLastPerformTraversalsSkipDrawReason = cancelDueToPreDrawListener
                ? "predraw_" + mAttachInfo.mTreeObserver.getLastDispatchOnPreDrawCanceledReason()
@@ -3895,8 +3895,8 @@ public final class ViewRootImpl implements ViewParent,
                mPendingTransitions.clear();
            }
            if (!performDraw(mActiveSurfaceSyncGroup)) {
                handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mPendingTransaction,
                        mLastPerformDrawSkippedReason);
                handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mHasPendingTransactions,
                        mPendingTransaction, mLastPerformDrawSkippedReason);
            }
        }

@@ -4774,8 +4774,8 @@ public final class ViewRootImpl implements ViewParent,
            if (mSurfaceHolder != null && mSurface.isValid()) {
                usingAsyncReport = true;
                SurfaceCallbackHelper sch = new SurfaceCallbackHelper(() -> {
                    handleSyncRequestWhenNoAsyncDraw(surfaceSyncGroup, pendingTransaction,
                            "SurfaceHolder");
                    handleSyncRequestWhenNoAsyncDraw(surfaceSyncGroup, pendingTransaction != null,
                            pendingTransaction, "SurfaceHolder");
                });

                SurfaceHolder.Callback callbacks[] = mSurfaceHolder.getCallbacks();
@@ -4789,8 +4789,8 @@ public final class ViewRootImpl implements ViewParent,
        }

        if (!usingAsyncReport) {
            handleSyncRequestWhenNoAsyncDraw(surfaceSyncGroup, pendingTransaction,
                    "no async report");
            handleSyncRequestWhenNoAsyncDraw(surfaceSyncGroup, pendingTransaction != null,
                    pendingTransaction, "no async report");
        }

        if (mPerformContentCapture) {
@@ -4800,13 +4800,14 @@ public final class ViewRootImpl implements ViewParent,
    }

    private void handleSyncRequestWhenNoAsyncDraw(SurfaceSyncGroup surfaceSyncGroup,
            @Nullable Transaction pendingTransaction, String logReason) {
            boolean hasPendingTransaction, @Nullable Transaction pendingTransaction,
            String logReason) {
        if (surfaceSyncGroup != null) {
            if (pendingTransaction != null) {
            if (hasPendingTransaction && pendingTransaction != null) {
                surfaceSyncGroup.addTransaction(pendingTransaction);
            }
            surfaceSyncGroup.markSyncReady();
        } else if (pendingTransaction != null) {
        } else if (hasPendingTransaction && pendingTransaction != null) {
            Trace.instant(Trace.TRACE_TAG_VIEW,
                    "Transaction not synced due to " + logReason + "-" + mTag);
            if (DEBUG_BLAST) {
@@ -9027,8 +9028,8 @@ public final class ViewRootImpl implements ViewParent,
            mAdded = false;
            AnimationHandler.removeRequestor(this);
        }
        handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mPendingTransaction,
                "shutting down VRI");
        handleSyncRequestWhenNoAsyncDraw(mActiveSurfaceSyncGroup, mHasPendingTransactions,
                mPendingTransaction, "shutting down VRI");
        WindowManagerGlobal.getInstance().doRemoveView(this);
    }