Merge "Always apply postDrawTransaction started during sync" into sc-v2-dev am: fc6e6de542

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15670080

Change-Id: I2d40ab0a08535ebc3d3b3cf15ae8c3e6090fd503
This commit is contained in:
Evan Rosky
2021-09-15 00:23:08 +00:00
committed by Automerger Merge Worker
2 changed files with 25 additions and 5 deletions

View File

@@ -371,6 +371,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
private int mResizeMode; private int mResizeMode;
private boolean mRedrawForSyncReported; private boolean mRedrawForSyncReported;
/**
* {@code true} when the client was still drawing for sync when the sync-set was finished or
* cancelled. This can happen if the window goes away during a sync. In this situation we need
* to make sure to still apply the postDrawTransaction when it finishes to prevent the client
* from getting stuck in a bad state.
*/
boolean mClientWasDrawingForSync = false;
/** /**
* Special mode that is intended only for the rounded corner overlay: during rotation * Special mode that is intended only for the rounded corner overlay: during rotation
* transition, we un-rotate the window token such that the window appears as it did before the * transition, we un-rotate the window token such that the window appears as it did before the
@@ -6009,6 +6017,14 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
return super.isSyncFinished(); return super.isSyncFinished();
} }
@Override
void finishSync(Transaction outMergedTransaction, boolean cancel) {
if (mSyncState == SYNC_STATE_WAITING_FOR_DRAW && mRedrawForSyncReported) {
mClientWasDrawingForSync = true;
}
super.finishSync(outMergedTransaction, cancel);
}
boolean finishDrawing(SurfaceControl.Transaction postDrawTransaction) { boolean finishDrawing(SurfaceControl.Transaction postDrawTransaction) {
if (mOrientationChangeRedrawRequestTime > 0) { if (mOrientationChangeRedrawRequestTime > 0) {
final long duration = final long duration =
@@ -6024,8 +6040,11 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
} }
executeDrawHandlers(postDrawTransaction); executeDrawHandlers(postDrawTransaction);
final boolean applyPostDrawNow = mClientWasDrawingForSync && postDrawTransaction != null;
mClientWasDrawingForSync = false;
if (!onSyncFinishedDrawing()) { if (!onSyncFinishedDrawing()) {
return mWinAnimator.finishDrawingLocked(postDrawTransaction); return mWinAnimator.finishDrawingLocked(postDrawTransaction, applyPostDrawNow);
} }
if (mActivityRecord != null if (mActivityRecord != null
@@ -6039,7 +6058,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
mSyncTransaction.merge(postDrawTransaction); mSyncTransaction.merge(postDrawTransaction);
} }
mWinAnimator.finishDrawingLocked(null); mWinAnimator.finishDrawingLocked(null, false /* forceApplyNow */);
// We always want to force a traversal after a finish draw for blast sync. // We always want to force a traversal after a finish draw for blast sync.
return true; return true;
} }

View File

@@ -228,7 +228,8 @@ class WindowStateAnimator {
} }
} }
boolean finishDrawingLocked(SurfaceControl.Transaction postDrawTransaction) { boolean finishDrawingLocked(SurfaceControl.Transaction postDrawTransaction,
boolean forceApplyNow) {
final boolean startingWindow = final boolean startingWindow =
mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; mWin.mAttrs.type == WindowManager.LayoutParams.TYPE_APPLICATION_STARTING;
if (startingWindow) { if (startingWindow) {
@@ -253,11 +254,11 @@ class WindowStateAnimator {
// If there is no surface, the last draw was for the previous surface. We don't want to // If there is no surface, the last draw was for the previous surface. We don't want to
// wait until the new surface is shown and instead just apply the transaction right // wait until the new surface is shown and instead just apply the transaction right
// away. // away.
if (mLastHidden && mDrawState != NO_SURFACE) { if (mLastHidden && mDrawState != NO_SURFACE && !forceApplyNow) {
mPostDrawTransaction.merge(postDrawTransaction); mPostDrawTransaction.merge(postDrawTransaction);
layoutNeeded = true; layoutNeeded = true;
} else { } else {
postDrawTransaction.apply(); mWin.getSyncTransaction().merge(postDrawTransaction);
} }
} }