From 225ea651900832384381b6e1022226f7531d0929 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Thu, 11 Mar 2021 21:10:03 -0800 Subject: [PATCH] WindowManager: Handle main window size change transaction with BLAST. Rather than push and defer the pending transaction we can use the new applyWithNextDraw primitive to make sure the transaction applies with the app redraw. We need to be a little careful. Since mainWindowSizeTransaction is consumed during layout, we need to move the check for pending draw handlers to the end of relayout. Test: Existing tests pass Bug: 168505645 Change-Id: Iae7906ee6def94ee3adc71b5f5ba022157379c73 --- .../server/wm/WindowStateAnimator.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 3ef7ccd6bfabf..ca38bb90f19cd 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -538,21 +538,17 @@ class WindowStateAnimator { // The sync transaction will contain the buffer so the bounds change transaction // will only be applied with the buffer. t.merge(task.getMainWindowSizeChangeTransaction()); + task.setMainWindowSizeChangeTransaction(null); } else { - // Use pending transaction here instead of the transaction passed in because we - // want to ensure the defer transaction is applied on the main transaction and - // not on the sync transaction. This is because the sync transaction could - // contain the buffer and we'd defer the transaction that contains the buffer - // we're deferring on. - SurfaceControl.Transaction pendingTransaction = mWin.getPendingTransaction(); - pendingTransaction.deferTransactionUntil( - task.getMainWindowSizeChangeTask().getSurfaceControl(), - mWin.getClientViewRootSurface(), mWin.getFrameNumber()); - pendingTransaction.deferTransactionUntil(mSurfaceController.mSurfaceControl, - mWin.getClientViewRootSurface(), mWin.getFrameNumber()); - pendingTransaction.merge(task.getMainWindowSizeChangeTransaction()); + mWin.applyWithNextDraw(finishedFrame -> { + final SurfaceControl.Transaction sizeChangedTransaction = + task.getMainWindowSizeChangeTransaction(); + if (sizeChangedTransaction != null) { + finishedFrame.merge(sizeChangedTransaction); + task.setMainWindowSizeChangeTransaction(null); + } + }); } - task.setMainWindowSizeChangeTransaction(null); } }