Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72d6dc3b authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Avoid flicker by finishing recents animation with config change

When finishing recents animation, the surface of closing app
will reparent to the original parent, and then the transition
TRANSIT_NONE executes directly that sets the closing app to
invisible and notify the opening app is ready. If the opening
app is in different orientation, DisplayContent#mWaitingForConfig
will be set. So the next round of surface traversal is skipped
and the invisible state hasn't applied to surface that causes
flicker.

With performing surface placement at the end of finishing recents
animation if there still has unfinished layout, that makes sure
any state changes of the window will be updated to its surface.

Also removed unused parameter recoveringMemory.

Bug: 151727009
Test: Enable fixed rotation transform and gesture navigation,
      swipe to home from a landscape activity.

Change-Id: I322fe376b0fe79ab58cb12ff99fc9749e00ef0c5
parent 984f629a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -3209,7 +3209,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
            if (mode == UPDATE_FOCUS_PLACING_SURFACES) {
                performLayout(true /*initial*/, updateInputWindows);
            } else if (mode == UPDATE_FOCUS_REMOVING_FOCUS) {
                mWmService.mRoot.performSurfacePlacement(false);
                mWmService.mRoot.performSurfacePlacement();
            }
        }

@@ -3846,7 +3846,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    }

    // TODO: Super crazy long method that should be broken down...
    void applySurfaceChangesTransaction(boolean recoveringMemory) {
    void applySurfaceChangesTransaction() {
        final WindowSurfacePlacer surfacePlacer = mWmService.mWindowPlacerLocked;

        mTmpUpdateAllDrawn.clear();
+6 −0
Original line number Diff line number Diff line
@@ -400,6 +400,12 @@ class RecentsAnimation implements RecentsAnimationCallbacks,
                    throw e;
                } finally {
                    mService.continueWindowLayout();
                    // Make sure the surfaces are updated with the latest state. Sometimes the
                    // surface placement may be skipped if display configuration is changed (i.e.
                    // {@link DisplayContent#mWaitingForConfig} is true).
                    if (mWindowManager.mRoot.isLayoutNeeded()) {
                        mWindowManager.mRoot.performSurfacePlacement();
                    }
                    Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
                }
            });
+6 −6
Original line number Diff line number Diff line
@@ -796,10 +796,10 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        return leakedSurface || killedApps;
    }

    void performSurfacePlacement(boolean recoveringMemory) {
    void performSurfacePlacement() {
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "performSurfacePlacement");
        try {
            performSurfacePlacementNoTrace(recoveringMemory);
            performSurfacePlacementNoTrace();
        } finally {
            Trace.traceEnd(TRACE_TAG_WINDOW_MANAGER);
        }
@@ -807,7 +807,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>

    // "Something has changed!  Let's make it correct now."
    // TODO: Super crazy long method that should be broken down...
    void performSurfacePlacementNoTrace(boolean recoveringMemory) {
    void performSurfacePlacementNoTrace() {
        if (DEBUG_WINDOW_TRACE) Slog.v(TAG, "performSurfacePlacementInner: entry. Called by "
                + Debug.getCallers(3));

@@ -842,7 +842,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        Trace.traceBegin(TRACE_TAG_WINDOW_MANAGER, "applySurfaceChanges");
        mWmService.openSurfaceTransaction();
        try {
            applySurfaceChangesTransaction(recoveringMemory);
            applySurfaceChangesTransaction();
        } catch (RuntimeException e) {
            Slog.wtf(TAG, "Unhandled exception in Window Manager", e);
        } finally {
@@ -1042,7 +1042,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        }
    }

    private void applySurfaceChangesTransaction(boolean recoveringMemory) {
    private void applySurfaceChangesTransaction() {
        mHoldScreenWindow = null;
        mObscuringWindow = null;

@@ -1065,7 +1065,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
        final int count = mChildren.size();
        for (int j = 0; j < count; ++j) {
            final DisplayContent dc = mChildren.get(j);
            dc.applySurfaceChangesTransaction(recoveringMemory);
            dc.applySurfaceChangesTransaction();
        }

        // Give the display manager a chance to adjust properties like display rotation if it needs
+1 −3
Original line number Diff line number Diff line
@@ -157,9 +157,7 @@ class WindowSurfacePlacer {

        mInLayout = true;

        boolean recoveringMemory = false;
        if (!mService.mForceRemoves.isEmpty()) {
            recoveringMemory = true;
            // Wait a little bit for things to settle down, and off we go.
            while (!mService.mForceRemoves.isEmpty()) {
                final WindowState ws = mService.mForceRemoves.remove(0);
@@ -177,7 +175,7 @@ class WindowSurfacePlacer {
        }

        try {
            mService.mRoot.performSurfacePlacement(recoveringMemory);
            mService.mRoot.performSurfacePlacement();

            mInLayout = false;

+1 −3
Original line number Diff line number Diff line
@@ -28,7 +28,6 @@ import static android.view.WindowManager.TRANSIT_KEYGUARD_UNOCCLUDE;

import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;

import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;

@@ -38,7 +37,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;

import android.graphics.Rect;
import android.os.IBinder;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
@@ -70,7 +68,7 @@ public class AppTransitionTests extends WindowTestsBase {

    @Before
    public void setUp() throws Exception {
        doNothing().when(mWm.mRoot).performSurfacePlacement(anyBoolean());
        doNothing().when(mWm.mRoot).performSurfacePlacement();
        mDc = mWm.getDefaultDisplayContentLocked();
    }

Loading