From 56966cba35348ec0359abae9653295f02ec73f30 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 30 Jul 2021 22:08:46 +0800 Subject: [PATCH] Allow to transfer starting window from dying activity If a launching activity with starting window is died and there is an activity in the same task, the starting window may be removed before the next activity is drawn. The symptom will be obvious if the next activity is slow to draw (black screen). Another symptom is that if the launching activity requested different orientation from the display, its rotation transform will be canceled when removing the activity. That causes the starting window shows in previous orientation temporally. Bug: 191429072 Test: Start a new activity on a standalone process into an existing task. The activity calls finish and kills itself in onCreate. Change-Id: Icc687854f9885389aa436b617c4bcb231a74c42c --- .../java/com/android/server/wm/ActivityRecord.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 5970f622955ec..3b5bbb3976cb9 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -3633,6 +3633,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } cleanUp(true /* cleanServices */, true /* setState */); if (remove) { + if (mStartingData != null && mVisible && task != null) { + // A corner case that the app terminates its trampoline activity on a separated + // process by killing itself. Transfer the starting window to the next activity + // which will be visible, so the dead activity can be removed immediately (no + // longer animating) and the reveal animation can play normally on next activity. + final ActivityRecord top = task.topRunningActivity(); + if (top != null && !top.mVisible && top.shouldBeVisible()) { + top.transferStartingWindow(this); + } + } removeFromHistory("appDied"); } }