Wait for attachment in Activity syncEngine

There is a race between starting-window finishDraw and app
attachment on cold-start. If the starting-window finishes first,
the transition won't know if there is an associated display
rotation. This results in the launch transition playing early
but into the wrong rotation. Once the app does attach, a new
transition will be created for the display rotation yielding
an ugly animation.

Solve this by just waiting for attachment before reporting
syncFinished (after checking visibleRequested).

Bug: 202201326
Test: cold-launch activity into a different rotation many times
      and observe 1 transition instead of 2.
Change-Id: I744e8d35b4a11200be2374ca923ed9606e619977
This commit is contained in:
Evan Rosky
2022-01-26 16:39:34 -08:00
parent 0e688c8247
commit 0c9aed6775

View File

@@ -9350,6 +9350,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
boolean isSyncFinished() {
if (!super.isSyncFinished()) return false;
if (!isVisibleRequested()) return true;
// Wait for attach. That is the earliest time where we know if there will be an associated
// display rotation. If we don't wait, the starting-window can finishDrawing first and
// cause the display rotation to end-up in a following transition.
if (!isAttached()) return false;
// If visibleRequested, wait for at-least one visible child.
for (int i = mChildren.size() - 1; i >= 0; --i) {
if (mChildren.get(i).isVisibleRequested()) {