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

Commit 6e2f0aae authored by Riddle Hsu's avatar Riddle Hsu
Browse files

Boost remote animation process earlier

Previously, the animating state of remote process is updated when the
transition is ready, which means that it waits until the opening apps
are drawn. Now it updates the state when requesting transition.

This can benefit 2 cases:
1. Launch apps from home
It can avoid flipping process scheduling group of home with
top->foreground->top during transition. Because the sequence is:
"home is top activity" -> "the launching app becomes top activity"
-> "home is running transition animation".

2. Swipe up to return to home
The activity lifecycle callbacks and the first frame of home can
almost always run on big cores.

Fix: 300535986
Test: atest TransitionTests#testRunningRemoteTransition
Change-Id: I80bc98468a3bd0011efa996bf7a54a1e7ae7059b
parent 65959325
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -173,7 +173,6 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
    private final TransitionController mController;
    private final BLASTSyncEngine mSyncEngine;
    private final Token mToken;
    private IApplicationThread mRemoteAnimApp;

    private @Nullable ActivityRecord mPipActivity;

@@ -1487,13 +1486,14 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        return mForcePlaying;
    }

    /** Adjusts the priority of the process which will run the transition animation. */
    void setRemoteAnimationApp(IApplicationThread app) {
        mRemoteAnimApp = app;
        final WindowProcessController wpc = mController.mAtm.getProcessController(app);
        if (wpc != null) {
            // This is an early prediction. If the process doesn't ack the animation in 200 ms,
            // the priority will be restored.
            mController.mRemotePlayer.update(wpc, true /* running */, true /* predict */);
        }

    /** Returns the app which will run the transition animation. */
    IApplicationThread getRemoteAnimationApp() {
        return mRemoteAnimApp;
    }

    void setNoAnimation(WindowContainer wc) {
+1 −7
Original line number Diff line number Diff line
@@ -1251,13 +1251,7 @@ class TransitionController {
        } else if (mPlayingTransitions.isEmpty()) {
            mTransitionPlayerProc.setRunningRemoteAnimation(false);
            mRemotePlayer.clear();
            return;
        }
        final IApplicationThread appThread = transition.getRemoteAnimationApp();
        if (appThread == null || appThread == mTransitionPlayerProc.getThread()) return;
        final WindowProcessController delegate = mAtm.getProcessController(appThread);
        if (delegate == null) return;
        mRemotePlayer.update(delegate, isPlaying, true /* predict */);
    }

    /** Called when a transition is aborted. This should only be called by {@link Transition} */
@@ -1483,7 +1477,7 @@ class TransitionController {
     * {@link #mTransitionPlayerProc}.
     */
    static class RemotePlayer {
        private static final long REPORT_RUNNING_GRACE_PERIOD_MS = 100;
        private static final long REPORT_RUNNING_GRACE_PERIOD_MS = 200;
        @GuardedBy("itself")
        private final ArrayMap<IBinder, DelegateProcess> mDelegateProcesses = new ArrayMap<>();
        private final ActivityTaskManagerService mAtm;
+1 −1
Original line number Diff line number Diff line
@@ -636,6 +636,7 @@ public class TransitionTests extends WindowTestsBase {
        transition.collect(app);
        controller.requestStartTransition(transition, null /* startTask */, remoteTransition,
                null /* displayChange */);
        assertTrue(delegateProc.isRunningRemoteTransition());
        testPlayer.startTransition();
        app.onStartingWindowDrawn();
        // The task appeared event should be deferred until transition ready.
@@ -643,7 +644,6 @@ public class TransitionTests extends WindowTestsBase {
        testPlayer.onTransactionReady(app.getSyncTransaction());
        assertTrue(task.taskAppearedReady());
        assertTrue(playerProc.isRunningRemoteTransition());
        assertTrue(delegateProc.isRunningRemoteTransition());
        assertTrue(controller.mRemotePlayer.reportRunning(delegateProc.getThread()));
        assertTrue(app.isVisible());