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

Commit ed5424f5 authored by Ikram Gabiyev's avatar Ikram Gabiyev
Browse files

No-op queued transition if display chng populating

If a transition is queued when a display changing transition
is still collecting and hasn't been "populated"/"formally started"
yet, then make sure we send that transition to Shell as no-op
where it will be aborted
Do this when once the transition starts collecting
when being popped off the queue.

Bug: 409386802
Flag: EXEMPT bugfix
Test: atest PinnedStackTests#testPinnedStackInBoundsAfterRotation
Change-Id: I0c4a242cfe9209c4b5e5309b32e139fc4abcb253
parent 613bf477
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -708,6 +708,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
        return mState == STATE_STARTED;
    }

    boolean hasStarted() {
        return mState >= STATE_STARTED;
    }

    boolean isPlaying() {
        return mState == STATE_PLAYING;
    }
+23 −1
Original line number Diff line number Diff line
@@ -180,6 +180,7 @@ class TransitionController {
        final Transition mTransition;
        final OnStartCollect mOnStartCollect;
        final BLASTSyncEngine.SyncGroup mLegacySync;
        boolean mShouldNoopUponDequeue;

        QueuedTransition(Transition transition, OnStartCollect onStartCollect) {
            mTransition = transition;
@@ -1164,6 +1165,14 @@ class TransitionController {
            // do collect things it can cause problems). So, we need to run it's onCollectStarted
            // immediately.
            queued.mOnStartCollect.onCollectStarted(true /* deferred */);
        } else if (queued.mTransition != null && queued.mShouldNoopUponDequeue) {
            // This transition was queued at a time when the collecting transition might have left
            // the incoming transition's changes stale (e.g. display change transition had not
            // been formally started). So send this transition to Shell before applying any changes
            // to report it as a no-op.
            ProtoLog.w(WmProtoLogGroups.WM_DEBUG_WINDOW_TRANSITIONS_MIN,
                    "Formerly queued #%d force-reported as no-op", queued.mTransition.getSyncId());
            queued.mTransition.setAllReady();
        } else {
            // Post this so that the now-playing transition logic isn't interrupted.
            mAtm.mH.post(() -> {
@@ -1495,7 +1504,20 @@ class TransitionController {

    /** Returns {@code true} if it started collecting, {@code false} if it was queued. */
    private void queueTransition(Transition transit, OnStartCollect onStartCollect) {
        mQueuedTransitions.add(new QueuedTransition(transit, onStartCollect));
        final QueuedTransition queuedTransition = new QueuedTransition(transit, onStartCollect);

        // If we queue a transition while a collecting transition is still not formally started,
        // then check if collecting transition is changing a display
        if (mCollectingTransition != null && !mCollectingTransition.hasStarted()) {
            for (int i = 0; i < mCollectingTransition.mParticipants.size(); i++) {
                if (mCollectingTransition.mParticipants.valueAt(i).asDisplayContent() != null) {
                    queuedTransition.mShouldNoopUponDequeue = true;
                    break;
                }
            }
        }

        mQueuedTransitions.add(queuedTransition);
        ProtoLog.v(WmProtoLogGroups.WM_DEBUG_WINDOW_TRANSITIONS_MIN,
                "Queueing transition: %s", transit);
    }