From 09286c9e30d2781a5687c422bbe215e09851f10c Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Thu, 15 Feb 2018 13:52:31 -0800 Subject: [PATCH] Remove mResizedWhileNotDragResizing This codepath is fundamentally broken with the hierarchy model. It's intended operation is such: Preserve the WindowStateAnimator level surface freezing updates to it, while waiting for a new surface to draw at a new size. Once the new surface has drawn, show it at a new position while hiding the preserved surface. Via this mechanism it could achieve atomic updates of size and position. However position is now handled at the WindowState level and so preserving the WindowStateAnimator surface doesn't achieve the intended affect of freezing the position. Furthermore the new location for setting the flag (WindowState#onResized) seems to have issues as it is now being triggered during resize. This is triggering Surface preservation during rotation making seamless rotation impossible. It also causes issues in other resize scenarios (drag resizing, PiP, virtual display (b/72220802)) and so we have to disable it bit by bit. We still have some need for atomic update of size and position but the solution is unlikely to resemble this code and so it seems best to remove it for now. Bug: 72038766 Bug: 72220802 Test: Manual. go/wm-smoke Change-Id: I6f2f5f6b26957ffa49c0bbaae5e099abf13ac47a --- .../com/android/server/wm/WindowState.java | 61 +------------------ .../server/wm/WindowStateAnimator.java | 5 -- 2 files changed, 3 insertions(+), 63 deletions(-) diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index c1a1452dae3de..3a818955c6149 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -600,12 +600,6 @@ class WindowState extends WindowContainer implements WindowManagerP */ boolean mResizedWhileGone = false; - /** @see #isResizedWhileNotDragResizing(). */ - private boolean mResizedWhileNotDragResizing; - - /** @see #isResizedWhileNotDragResizingReported(). */ - private boolean mResizedWhileNotDragResizingReported; - /** * During seamless rotation we have two phases, first the old window contents * are rotated to look as if they didn't move in the new coordinate system. Then we @@ -1280,7 +1274,6 @@ class WindowState extends WindowContainer implements WindowManagerP || mDisplayCutoutChanged || configChanged || dragResizingChanged - || !isResizedWhileNotDragResizingReported() || mReportOrientationChanged) { if (DEBUG_RESIZE || DEBUG_ORIENTATION) { Slog.v(TAG_WM, "Resize reasons for w=" + this + ": " @@ -1295,8 +1288,6 @@ class WindowState extends WindowContainer implements WindowManagerP + " surfaceResized=" + winAnimator.mSurfaceResized + " configChanged=" + configChanged + " dragResizingChanged=" + dragResizingChanged - + " resizedWhileNotDragResizingReported=" - + isResizedWhileNotDragResizingReported() + " reportOrientationChanged=" + mReportOrientationChanged + " displayCutoutChanged=" + mDisplayCutoutChanged); } @@ -1315,8 +1306,7 @@ class WindowState extends WindowContainer implements WindowManagerP // then we need to hold off on unfreezing the display until this window has been // redrawn; to do that, we need to go through the process of getting informed by the // application when it has finished drawing. - if (getOrientationChanging() || dragResizingChanged - || isResizedWhileNotDragResizing()) { + if (getOrientationChanging() || dragResizingChanged) { if (DEBUG_ANIM || DEBUG_ORIENTATION || DEBUG_RESIZE) { Slog.v(TAG_WM, "Orientation or resize start waiting for draw" + ", mDrawState=DRAW_PENDING in " + this @@ -1744,22 +1734,6 @@ class WindowState extends WindowContainer implements WindowManagerP if (mHasSurface && !resizingWindows.contains(this)) { if (DEBUG_RESIZE) Slog.d(TAG, "onResize: Resizing " + this); resizingWindows.add(this); - - // If we are not drag resizing, force recreating of a new surface so updating - // the content and positioning that surface will be in sync. - // - // As we use this flag as a hint to freeze surface boundary updates, we'd like to only - // apply this to TYPE_BASE_APPLICATION, windows of TYPE_APPLICATION like dialogs, could - // appear to not be drag resizing while they resize, but we'd still like to manipulate - // their frame to update crop, etc... - // - // Anyway we don't need to synchronize position and content updates for these - // windows since they aren't at the base layer and could be moved around anyway. - if (!computeDragResizing() && mAttrs.type == TYPE_BASE_APPLICATION - && !mWinAnimator.isForceScaled() && !isGoneForLayoutLw() - && !getTask().inPinnedWindowingMode()) { - setResizedWhileNotDragResizing(true); - } } if (isGoneForLayoutLw()) { mResizedWhileGone = true; @@ -2944,7 +2918,6 @@ class WindowState extends WindowContainer implements WindowManagerP mOutsetsChanged = false; mFrameSizeChanged = false; mDisplayCutoutChanged = false; - mResizedWhileNotDragResizingReported = true; mWinAnimator.mSurfaceResized = false; mReportOrientationChanged = false; } catch (RemoteException e) { @@ -2989,8 +2962,7 @@ class WindowState extends WindowContainer implements WindowManagerP MergedConfiguration mergedConfiguration, boolean reportOrientation, int displayId, DisplayCutout displayCutout) throws RemoteException { - final boolean forceRelayout = isDragResizeChanged() || mResizedWhileNotDragResizing - || reportOrientation; + final boolean forceRelayout = isDragResizeChanged() || reportOrientation; mClient.resized(frame, overscanInsets, contentInsets, visibleInsets, stableInsets, outsets, reportDraw, mergedConfiguration, getBackdropFrame(frame), forceRelayout, @@ -3092,32 +3064,6 @@ class WindowState extends WindowContainer implements WindowManagerP super.resetDragResizingChangeReported(); } - /** - * Set whether we got resized but drag resizing flag was false. - * @see #isResizedWhileNotDragResizing(). - */ - private void setResizedWhileNotDragResizing(boolean resizedWhileNotDragResizing) { - mResizedWhileNotDragResizing = resizedWhileNotDragResizing; - mResizedWhileNotDragResizingReported = !resizedWhileNotDragResizing; - } - - /** - * Indicates whether we got resized but drag resizing flag was false. In this case, we also - * need to recreate the surface and defer surface bound updates in order to make sure the - * buffer contents and the positioning/size stay in sync. - */ - boolean isResizedWhileNotDragResizing() { - return mResizedWhileNotDragResizing; - } - - /** - * @return Whether we reported "resize while not drag resizing" to the application. - * @see #isResizedWhileNotDragResizing() - */ - private boolean isResizedWhileNotDragResizingReported() { - return mResizedWhileNotDragResizingReported; - } - int getResizeMode() { return mResizeMode; } @@ -4359,12 +4305,11 @@ class WindowState extends WindowContainer implements WindowManagerP // stack since it can lead to issues if a new surface is created while calculating the // scale for the animation using the source hint rect // (see WindowStateAnimator#setSurfaceBoundariesLocked()). - if (isDragResizeChanged() || isResizedWhileNotDragResizing() + if (isDragResizeChanged() || (surfaceInsetsChanging() && !inPinnedWindowingMode())) { mLastSurfaceInsets.set(mAttrs.surfaceInsets); setDragResizing(); - setResizedWhileNotDragResizing(false); // We can only change top level windows to the full-screen surface when // resizing (as we only have one full-screen surface). So there is no need // to preserve and destroy windows which are attached to another, they diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index a699ba00cd4e7..eeefcf5566846 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -841,11 +841,6 @@ class WindowStateAnimator { final LayoutParams attrs = mWin.getAttrs(); final Task task = w.getTask(); - // We got resized, so block all updates until we got the new surface. - if (w.isResizedWhileNotDragResizing() && !w.isGoneForLayoutLw()) { - return; - } - mTmpSize.set(w.mShownPosition.x, w.mShownPosition.y, 0, 0); calculateSurfaceBounds(w, attrs);