summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chavi Weingarten <chaviw@google.com> 2023-10-10 16:17:33 +0000
committer Chavi Weingarten <chaviw@google.com> 2023-10-10 16:17:33 +0000
commit92c579be7d9bb0d2eb39c75939c56fb81e4466ac (patch)
tree92af5b739018d9145ea9a7421a38dba86f425bde
parentc7170612248a588ac508fa9c6a58cfec99d78c73 (diff)
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
-rw-r--r--core/java/android/view/ViewRootImpl.java27
1 files changed, 14 insertions, 13 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index cf46bcccdf87..0f7bc215dc9d 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -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);
}