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

Commit 1357e7a8 authored by Robin Lee's avatar Robin Lee
Browse files

Workaround missing display leashes

There is some sequencing problem where display leashes aren't
present in time to use them for transitions on that display.

When TransitionHandlers were reparenting to the null display leashes,
that would be treated as just moving them offscreen. However,
relZ-reparenting to null is not allowed and so this recently became
the source of crashes during CTS tests.

Raise a Log.wtf for investigation, but don't crash the system ui process
any more.

Test: None
Bug: 420068074
Flag: EXEMPT BUGFIX
Change-Id: I8bb6307590dcc73f08f48a2d7799fa09a45c9b49
parent d9d33b67
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ import com.android.wm.shell.sysui.ShellInit;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.Executor;

/** Display area organizer for the root/default TaskDisplayAreas */
@@ -125,10 +126,17 @@ public class RootTaskDisplayAreaOrganizer extends DisplayAreaOrganizer {

    /**
     * Sets the layer of {@param sc} to be relative to the TDA on {@param displayId}.
     *
     * @throws NoSuchElementException if {@param displayId} has not appeared or has been removed.
     */
    public void relZToDisplayArea(int displayId, SurfaceControl sc, SurfaceControl.Transaction t,
            int z) {
        t.setRelativeLayer(sc, mLeashes.get(displayId), z);
        final SurfaceControl dsc = mLeashes.get(displayId);
        if (dsc != null) {
            t.setRelativeLayer(sc, dsc, z);
        } else {
            throw new NoSuchElementException("Display " + displayId + " is not registered");
        }
    }

    /**
+14 −5
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ import com.android.wm.shell.shared.animation.Interpolators;
import com.android.wm.shell.sysui.ShellInit;

import java.util.ArrayList;
import java.util.NoSuchElementException;

/** The default handler that handles anything not already handled. */
public class DefaultTransitionHandler implements Transitions.TransitionHandler {
@@ -693,6 +694,12 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
        final Color bgColor = Color.valueOf(color);
        final float[] colorArray = new float[] { bgColor.red(), bgColor.green(), bgColor.blue() };

        boolean isSplitTaskInvolved = false;
        for (var change : info.getChanges()) {
            isSplitTaskInvolved |= (change.getTaskInfo() != null
                    && change.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
        }

        for (int i = 0; i < info.getRootCount(); ++i) {
            final int displayId = info.getRoot(i).getDisplayId();
            final SurfaceControl backgroundSurface = new SurfaceControl.Builder()
@@ -709,12 +716,14 @@ public class DefaultTransitionHandler implements Transitions.TransitionHandler {
            // 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
            // above the display area when split is on.
            final boolean isSplitTaskInvolved =
                    info.getChanges().stream().anyMatch(c-> c.getTaskInfo() != null
                            && c.getTaskInfo().getWindowingMode() == WINDOWING_MODE_MULTI_WINDOW);
            if (isSplitTaskInvolved) {
                mRootTDAOrganizer.relZToDisplayArea(displayId, backgroundSurface, startTransaction,
                        -1);
                try {
                    mRootTDAOrganizer.relZToDisplayArea(
                            displayId, backgroundSurface, startTransaction, -1);
                } catch (NoSuchElementException e) {
                    ProtoLog.wtf(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
                            "Unable to add background because display %d does not exist",displayId);
                }
            }

            finishTransaction.remove(backgroundSurface);