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

Commit edd641cb authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Fix missing transition with visibility change when changing opaque

This aligns OPEN scene transition with CLOSE scene transition that
consists of 2 transitions:

OPEN = OPEN (startActivity) + TO_BACK (convertFromTranslucent)
CLOSE = TO_FRONT (converToTranslucent) + CLOSE (finish)

The TO_BACK was missing. That causes the visibility change to be
committed immediately with surface placement, which increases the
execution time of convertFromTranslucent.

Also removes requestTraversal because setOpaqueLocked will call
scheduleAnimation that is enough to update surface attributes.

Bug: 314261955
Test: UiBenchActivityTransitionsAnimationMicrobenchmark
Change-Id: I4c5e401c6f7fd53650ac49b527df98bc00b8534a
parent 02b61abc
Loading
Loading
Loading
Loading
+26 −13
Original line number Diff line number Diff line
@@ -421,8 +421,11 @@ public final class TransitionInfo implements Parcelable {
        final String perChangeLineStart = shouldPrettyPrint ? "\n" + innerPrefix : "";
        StringBuilder sb = new StringBuilder();
        sb.append("{id=").append(mDebugId).append(" t=").append(transitTypeToString(mType))
                .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack)
                .append(" r=[");
                .append(" f=0x").append(Integer.toHexString(mFlags)).append(" trk=").append(mTrack);
        if (mOptions != null) {
            sb.append(" opt=").append(mOptions);
        }
        sb.append(" r=[");
        for (int i = 0; i < mRoots.size(); ++i) {
            if (i > 0) {
                sb.append(',');
@@ -1211,21 +1214,31 @@ public final class TransitionInfo implements Parcelable {

        @NonNull
        private static String typeToString(int mode) {
            switch(mode) {
                case ANIM_CUSTOM: return "ANIM_CUSTOM";
                case ANIM_CLIP_REVEAL: return "ANIM_CLIP_REVEAL";
                case ANIM_SCALE_UP: return "ANIM_SCALE_UP";
                case ANIM_THUMBNAIL_SCALE_UP: return "ANIM_THUMBNAIL_SCALE_UP";
                case ANIM_THUMBNAIL_SCALE_DOWN: return "ANIM_THUMBNAIL_SCALE_DOWN";
                case ANIM_OPEN_CROSS_PROFILE_APPS: return "ANIM_OPEN_CROSS_PROFILE_APPS";
                default: return "<unknown:" + mode + ">";
            }
            return switch (mode) {
                case ANIM_CUSTOM -> "CUSTOM";
                case ANIM_SCALE_UP -> "SCALE_UP";
                case ANIM_THUMBNAIL_SCALE_UP -> "THUMBNAIL_SCALE_UP";
                case ANIM_THUMBNAIL_SCALE_DOWN -> "THUMBNAIL_SCALE_DOWN";
                case ANIM_SCENE_TRANSITION -> "SCENE_TRANSITION";
                case ANIM_CLIP_REVEAL -> "CLIP_REVEAL";
                case ANIM_OPEN_CROSS_PROFILE_APPS -> "OPEN_CROSS_PROFILE_APPS";
                case ANIM_FROM_STYLE -> "FROM_STYLE";
                default -> "<" + mode + ">";
            };
        }

        @Override
        public String toString() {
            return "{ AnimationOptions type= " + typeToString(mType) + " package=" + mPackageName
                    + " override=" + mOverrideTaskTransition + " b=" + mTransitionBounds + "}";
            final StringBuilder sb = new StringBuilder(32);
            sb.append("{t=").append(typeToString(mType));
            if (mOverrideTaskTransition) {
                sb.append(" overrideTask=true");
            }
            if (!mTransitionBounds.isEmpty()) {
                sb.append(" bounds=").append(mTransitionBounds);
            }
            sb.append('}');
            return sb.toString();
        }

        /** Customized activity transition. */
+8 −3
Original line number Diff line number Diff line
@@ -778,17 +778,22 @@ class ActivityClientController extends IActivityClientController.Stub {
        try {
            synchronized (mGlobalLock) {
                final ActivityRecord r = ActivityRecord.isInRootTaskLocked(token);
                if (r == null) {
                    return false;
                }
                // Create a transition if the activity is playing in case the below activity didn't
                // commit invisible. That's because if any activity below this one has changed its
                // visibility while playing transition, there won't able to commit visibility until
                // the running transition finish.
                final Transition transition = r != null
                        && r.mTransitionController.inPlayingTransition(r)
                final Transition transition = r.mTransitionController.isShellTransitionsEnabled()
                        && !r.mTransitionController.isCollecting()
                        ? r.mTransitionController.createTransition(TRANSIT_TO_BACK) : null;
                final boolean changed = r != null && r.setOccludesParent(true);
                final boolean changed = r.setOccludesParent(true);
                if (transition != null) {
                    if (changed) {
                        // Always set as scene transition because it expects to be a jump-cut.
                        transition.setOverrideAnimation(TransitionInfo.AnimationOptions
                                .makeSceneTransitionAnimOptions(), null, null);
                        r.mTransitionController.requestStartTransition(transition,
                                null /*startTask */, null /* remoteTransition */,
                                null /* displayChange */);
+0 −1
Original line number Diff line number Diff line
@@ -3093,7 +3093,6 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        final boolean changed = occludesParent != mOccludesParent;
        mOccludesParent = occludesParent;
        setMainWindowOpaque(occludesParent);
        mWmService.mWindowPlacerLocked.requestTraversal();

        if (changed && task != null && !occludesParent) {
            getRootTask().convertActivityToTranslucent(this);