From 2162a2f2eb9b82390607f83dedf80b423c45aa78 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 5 May 2020 13:46:48 -0700 Subject: [PATCH] setBoundsChangeTransaction: Fix two issues 1. Ensure it only applies to the root of the task. This is to ensure we don't get tricked in to thinking the app is resizing when the PIP menu resizes. As a next step we still need to keep the PIP menu from resizing. 2. Also defer the Transaction on the Task SurfaceControl not just the Window itself. This was just a typo in the original implementation. Bug: 150810705 Test: Change PIP size. Main window is flicker free. Change-Id: I26d82b5f73110aaa8fe730edfd07c87e7cf84c0d --- .../server/wm/WindowStateAnimator.java | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 0e83beed6b905..c570cf1d949f7 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -846,6 +846,23 @@ class WindowStateAnimator { } } + private boolean shouldConsumeMainWindowSizeTransaction() { + // We only consume the transaction when the client is calling relayout + // because this is the only time we know the frameNumber will be valid + // due to the client renderer being paused. Put otherwise, only when + // mInRelayout is true can we guarantee the next frame will contain + // the most recent configuration. + if (!mWin.mInRelayout) return false; + // Since we can only do this for one window, we focus on the main application window + if (mAttrType != TYPE_BASE_APPLICATION) return false; + final Task task = mWin.getTask(); + if (task == null) return false; + if (task.getMainWindowSizeChangeTransaction() == null) return false; + // Likewise we only focus on the task root, since we can only use one window + if (!mWin.mActivityRecord.isRootOfTask()) return false; + return true; + } + void setSurfaceBoundariesLocked(final boolean recoveringMemory) { if (mSurfaceController == null) { return; @@ -886,8 +903,9 @@ class WindowStateAnimator { clipRect = mTmpClipRect; } - if (w.mInRelayout && (mAttrType == TYPE_BASE_APPLICATION) && (task != null) - && (task.getMainWindowSizeChangeTransaction() != null)) { + if (shouldConsumeMainWindowSizeTransaction()) { + task.getSurfaceControl().deferTransactionUntil(mWin.getClientViewRootSurface(), + mWin.getFrameNumber()); mSurfaceController.deferTransactionUntil(mWin.getClientViewRootSurface(), mWin.getFrameNumber()); SurfaceControl.mergeToGlobalTransaction(task.getMainWindowSizeChangeTransaction());