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

Commit a767d980 authored by Luca Zuccarini's avatar Luca Zuccarini
Browse files

Post the onTransitionAnimationEnd() work to the main thread.

This was already submitted but reverted due to the introduction of a
flicker. For now we're only re-enabling it for return animations, which
don't display the flicker.

Bug: 330672236
Flag: EXEMPT returns are flagged at usage site
Test: atest TransitionAnimatorTest
Change-Id: I35830caefde3d5371bee7b8b020c7b4bd07076a7
parent a0d91ba5
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -1006,8 +1006,7 @@ class TransitionAnimator(
            Log.d(TAG, "Animation ended")
        }

        // TODO(b/330672236): Post this to the main thread instead so that it does not
        // flicker with Flexiglass enabled.
        val onEnd = {
            controller.onTransitionAnimationEnd(isExpandingFullyAbove)
            transitionContainerOverlay.remove(windowBackgroundLayer)

@@ -1015,6 +1014,26 @@ class TransitionAnimator(
                openingWindowSyncViewOverlay?.remove(windowBackgroundLayer)
            }
        }
        // TODO(b/330672236): Post this to the main thread for launches as well, so that they do not
        //   flicker with Flexiglass enabled.
        if (controller.isLaunching) {
            onEnd()
        } else {
            // onAnimationEnd is called at the end of the animation, on a Choreographer animation
            // tick. During dialog launches, the following calls will move the animated content from
            // the dialog overlay back to its original position, and this change must be reflected
            // in the next frame given that we then sync the next frame of both the content and
            // dialog ViewRoots. During SysUI activity launches, we will instantly collapse the
            // shade at the end of the transition. However, if those are rendered by Compose, whose
            // compositions are also scheduled on a Choreographer frame, any state change made
            // *right now* won't be reflected in the next frame given that a Choreographer frame
            // can't schedule another and have it happen in the same frame. So we post the forwarded
            // calls to [Controller.onLaunchAnimationEnd] in the main executor, leaving this
            // Choreographer frame, ensuring that any state change applied by
            // onTransitionAnimationEnd() will be reflected in the same frame.
            mainExecutor.execute { onEnd() }
        }
    }

    /** Returns whether is the controller's view should be visible with the given [timings]. */
    private fun checkVisibility(timings: Timings, progress: Float, isLaunching: Boolean): Boolean {