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

Commit 04d425ba authored by Evan Rosky's avatar Evan Rosky Committed by Ikram Gabiyev
Browse files

Add workaround for PiP1 in sync-finished detection

To conservatively determine when a sync is finished (without
ready-tracking), we need to wait until visibility is calculated
after lifecycle events "settle". Unfortunately, pip1 is
sensitive to the time-spent waiting for lifecycle events to
complete (since it needs a "cleanup" transition to undo
an intermediate state it put WM in).

Until we have pip2, this CL works around this issue by
detecting this intermediate state and not-waiting. While
this technically creates a "gap" in ready detection, in
practice this situation should be rare outside of the
pip1 use-case.

Bug: 385852312
Test: 3btn-nav, go to pip, open another app, expand pip, re-enter
      pip quickly.
Flag: EXEMPT bugfix
Change-Id: Ic2f4a717d0d1c6429fc1eca9dfec27c00e9aa8c0
parent a309f14e
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -330,7 +330,6 @@ import android.view.RemoteAnimationDefinition;
import android.view.SurfaceControl;
import android.view.SurfaceControl.Transaction;
import android.view.WindowInsets;
import android.view.WindowInsets.Type;
import android.view.WindowManager;
import android.view.WindowManager.LayoutParams;
import android.view.WindowManager.TransitionOldType;
@@ -9713,7 +9712,18 @@ final class ActivityRecord extends WindowToken {
                    && !mDisplayContent.isSleeping()) {
                // Visibility of starting activities isn't calculated until pause-complete, so if
                // this is not paused yet, don't consider it ready.
                // However, due to pip1 having an intermediate state, add a special exception here
                // that skips waiting if the next activity is already visible.
                final ActivityRecord toResume = isPip2ExperimentEnabled() ? null
                        : mDisplayContent.getActivity((r) -> !r.finishing
                        && r.isVisibleRequested()
                        && !r.isTaskOverlay()
                        && !r.isAlwaysOnTop());
                if (toResume == null || !toResume.isVisible()) {
                    return false;
                } else {
                    Slog.i(TAG, "Assuming sync-finish while pausing due to visible target");
                }
            }
            return true;
        }