From 6a0777a1d778f6b469722b25a0e7645a2adce525 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Tue, 1 Jun 2021 14:28:55 +0800 Subject: [PATCH] Force relayout if sync operation is requested explicitly The initial value of WindowState#mRedrawForSyncReported is false. Then even if mSyncState is none and mPendingDrawHandlers is empty and Task#mMainindowSizeChangeTransaction is null, it still forces client to relayout. This change aligns the condition in updateResizingWindowIfNeeded that also checks shouldSendRedrawForSync. So if there is no explicit sync request, there won't be an extra relayout. Bug: 189915038 Test: CtsWindowManagerDeviceTestCases Test: Check trace of adding a new simple window. There should be only one traversal. Change-Id: Iad10034e29b9db50ec4221ac1a25f26ce6464393 --- .../java/com/android/server/wm/WindowState.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 5f47986501849..fa18641b3371a 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -3838,8 +3838,9 @@ class WindowState extends WindowContainer implements WindowManagerP fillClientWindowFramesAndConfiguration(mClientWindowFrames, mLastReportedConfiguration, true /* useLatestConfig */, false /* relayoutVisible */); - final boolean reportDraw = drawPending || useBLASTSync() || !mRedrawForSyncReported; - final boolean forceRelayout = reportOrientation || isDragResizeChanged() || !mRedrawForSyncReported; + final boolean syncRedraw = shouldSendRedrawForSync(); + final boolean reportDraw = syncRedraw || drawPending; + final boolean forceRelayout = syncRedraw || reportOrientation || isDragResizeChanged(); final DisplayContent displayContent = getDisplayContent(); final boolean alwaysConsumeSystemBars = displayContent.getDisplayPolicy().areSystemBarsForcedShownLw(this); @@ -5937,10 +5938,14 @@ class WindowState extends WindowContainer implements WindowManagerP * for Windows involved in these Syncs */ private boolean shouldSendRedrawForSync() { + if (mRedrawForSyncReported) { + return false; + } final Task task = getTask(); - if (task != null && task.getMainWindowSizeChangeTransaction() != null) - return !mRedrawForSyncReported; - return useBLASTSync() && !mRedrawForSyncReported; + if (task != null && task.getMainWindowSizeChangeTransaction() != null) { + return true; + } + return useBLASTSync(); } void requestRedrawForSync() {