From d7f9a3afa4f36868f8fd64ea33d3517dfd7482ad Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Wed, 31 Aug 2022 18:15:53 +0800 Subject: [PATCH] Complete sync draw only for visible window Otherwise the sync may be finished too early if the client performs relayout with View.INVISIBLE (e.g. the activity is stopping). Besides, window manager service should only consider View.VISIBLE as real visible. Bug: 240564946 Test: adb shell setprop persist.wm.debug.shell_transit 1; reboot atest CloseImeAutoOpenWindowToHomeTest Change-Id: I9a9868ba5a628b8fa7312380a5b1bb8148865f21 --- .../java/com/android/server/wm/WindowManagerService.java | 2 +- services/core/java/com/android/server/wm/WindowState.java | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 3f98ea59a0c06..828185fe6ed99 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2542,7 +2542,7 @@ public class WindowManagerService extends IWindowManager.Stub if (outSyncIdBundle != null) { final int maybeSyncSeqId; - if (USE_BLAST_SYNC && win.useBLASTSync() && viewVisibility != View.GONE + if (USE_BLAST_SYNC && win.useBLASTSync() && viewVisibility == View.VISIBLE && win.mSyncSeqId > lastSyncSeqId) { maybeSyncSeqId = win.shouldSyncWithBuffers() ? win.mSyncSeqId : -1; win.markRedrawForSyncReported(); diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 2e7e78db9e057..72d47c6bd7672 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -5953,10 +5953,10 @@ class WindowState extends WindowContainer implements WindowManagerP @Override boolean isSyncFinished() { - if (mSyncState == SYNC_STATE_WAITING_FOR_DRAW && mViewVisibility == View.GONE + if (mSyncState == SYNC_STATE_WAITING_FOR_DRAW && mViewVisibility != View.VISIBLE && !isVisibleRequested()) { - // Don't wait for GONE windows. However, we don't alter the state in case the window - // becomes un-gone while the syncset is still active. + // Don't wait for invisible windows. However, we don't alter the state in case the + // window becomes visible while the sync group is still active. return true; } return super.isSyncFinished();