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

Commit a2a3b187 authored by Evan Rosky's avatar Evan Rosky
Browse files

Make animation-background rel-z instead of reparented

For split, there were some situation where the animation-background
would be placed above (in Z) one of the split sides during
animation. This was originally resolved by putting the layer into
the root TDA. While this works, it relies on the finish transaction
being applied to clean it up. There are some situations where this
may not happen (for example if sysui process crashes) which can
leave the surface around "forever".

The transition root, however, is managed by Core so will be
cleaned up if sysui crashes, so it's more reliable if we can
leave the background as a child of that.

While neither of these is a very scalable solution, for the short
term: since the original issue was about z-order, we can replace
reparenting with rel-z so it will get cleaned-up with the
transition root.

Bug: 384435414
Test: launch task into other split to ensure nothing visual regressed
Flag: EXEMPT bugfix
Change-Id: Ied07853b17025829191dadb061960474b5d57890
parent e7ba61fd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -115,6 +115,14 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {
        b.setParent(sc);
    }

    /**
     * Sets the layer of {@param sc} to be relative to the TDA on {@param displayId}.
     */
    public void relZToDisplayArea(int displayId, SurfaceControl sc, SurfaceControl.Transaction t,
            int z) {
        t.setRelativeLayer(sc, mLeashes.get(displayId), z);
    }

    /**
     * Re-parents the provided surface to the leash of the provided display.
     *
+11 −10
Original line number Diff line number Diff line
@@ -650,10 +650,16 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {

        for (int i = 0; i < info.getRootCount(); ++i) {
            final int displayId = info.getRoot(i).getDisplayId();
            final SurfaceControl.Builder colorLayerBuilder = new SurfaceControl.Builder()
                    .setName("animation-background")
            final SurfaceControl backgroundSurface = new SurfaceControl.Builder()
                    .setName("animation-background for #" + info.getDebugId())
                    .setCallsite("DefaultTransitionHandler")
                    .setColorLayer();
                    .setColorLayer()
                    .setParent(info.getRoot(i).getLeash())
                    .build();

            startTransaction.setColor(backgroundSurface, colorArray)
                    .setLayer(backgroundSurface, -1)
                    .show(backgroundSurface);

            // Attaching the background surface to the transition root could unexpectedly make it
            // cover one of the split root tasks. To avoid this, put the background surface just
@@ -662,15 +668,10 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
                    info.getChanges().stream().anyMatch(c-> c.getTaskInfo() != null
                            && c.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
            if (isSplitTaskInvolved) {
                mRootTDAOrganizer.attachToDisplayArea(displayId, colorLayerBuilder);
            } else {
                colorLayerBuilder.setParent(info.getRootLeash());
                mRootTDAOrganizer.relZToDisplayArea(displayId, backgroundSurface, startTransaction,
                        -1);
            }

            final SurfaceControl backgroundSurface = colorLayerBuilder.build();
            startTransaction.setColor(backgroundSurface, colorArray)
                    .setLayer(backgroundSurface, -1)
                    .show(backgroundSurface);
            finishTransaction.remove(backgroundSurface);
        }
    }