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

Commit 3dac63a1 authored by Jorim Jaggi's avatar Jorim Jaggi
Browse files

Don't destroy thumbnails immediately

The hiding of the thumbnails needs to be synchronized with the hiding
of the app window. Because destroying them immediately destroys them
without being part of the transaction, that can happen earlier than
hiding the surface.

Instead, hide the thumbnail in the transaction first and then put it
into a list to be cleared after the transaction is closed.

Bug: 27275815
Change-Id: I1530262c26c0751e53d218b686c46129f7c7df1d
parent 713be06f
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -190,7 +190,8 @@ public class AppWindowAnimator {

    public void clearThumbnail() {
        if (thumbnail != null) {
            thumbnail.destroy();
            thumbnail.hide();
            mService.mWindowPlacerLocked.destroyAfterTransaction(thumbnail);
            thumbnail = null;
        }
        deferThumbnailDestruction = false;
+1 −0
Original line number Diff line number Diff line
@@ -771,6 +771,7 @@ public class WindowAnimator {
        }

        mService.destroyPreservedSurfaceLocked();
        mService.mWindowPlacerLocked.destroyPendingSurfaces();

        if (DEBUG_WINDOW_TRACE) {
            Slog.i(TAG, "!!! animate: exit mAnimating=" + mAnimating
+22 −1
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ import android.graphics.Canvas;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Debug;
import android.os.Message;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.SystemClock;
@@ -125,6 +124,8 @@ class WindowSurfacePlacer {
    }
    private final LayerAndToken mTmpLayerAndToken = new LayerAndToken();

    private final ArrayList<SurfaceControl> mPendingDestroyingSurfaces = new ArrayList<>();

    public WindowSurfacePlacer(WindowManagerService service) {
        mService = service;
        mWallpaperControllerLocked = mService.mWallpaperControllerLocked;
@@ -542,6 +543,7 @@ class WindowSurfacePlacer {
        mService.enableScreenIfNeededLocked();

        mService.scheduleAnimationLocked();
        mService.mWindowPlacerLocked.destroyPendingSurfaces();

        if (DEBUG_WINDOW_TRACE) Slog.e(TAG,
                "performSurfacePlacementInner exit: animating=" + mService.mAnimator.isAnimating());
@@ -1620,6 +1622,25 @@ class WindowSurfacePlacer {
        }
    }

    /**
     * Puts the {@param surface} into a pending list to be destroyed after the current transaction
     * has been committed.
     */
    void destroyAfterTransaction(SurfaceControl surface) {
        mPendingDestroyingSurfaces.add(surface);
    }

    /**
     * Destroys any surfaces that have been put into the pending list with
     * {@link #destroyAfterTransaction}.
     */
    void destroyPendingSurfaces() {
        for (int i = mPendingDestroyingSurfaces.size() - 1; i >= 0; i--) {
            mPendingDestroyingSurfaces.get(i).destroy();
        }
        mPendingDestroyingSurfaces.clear();
    }

    public void dump(PrintWriter pw, String prefix) {
        pw.print(prefix); pw.print("mTraversalScheduled="); pw.println(mTraversalScheduled);
    }