From 2173011b77579d460a4e3ec3a74c150d1ea1d9a7 Mon Sep 17 00:00:00 2001
From: yuanhuan <yuanhuan@oppo.com>
Date: Wed, 21 Feb 2024 17:28:27 +0800
Subject: [PATCH] Fix cold-lauch Activity Embeded apps flash black.

Before collect new created task fragment in createTaskFragment(),
recomputeConfiguration() will set a crop in PendingTransaction,which
will cause starting window be cropped before staring window reparent
to root task in SyncTransaction.So addToSyncSet() before
recomputeConfiguration().

Test: pressure test cold-lauch Activity Embeded apps and no flash black.
Bug: b/324148725

Change-Id: I7ded9adb1c52d61b700edfdc83e7929cff67e529
---
 .../com/android/server/wm/WindowOrganizerController.java     | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 9375b297be2b..ecdf09f698d1 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -2016,6 +2016,11 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
         ownerTask.addChild(taskFragment, position);
         taskFragment.setWindowingMode(creationParams.getWindowingMode());
         if (!creationParams.getInitialRelativeBounds().isEmpty()) {
+            // The surface operations for the task fragment should sync with the transition.
+            // This avoid using pending transaction before collectExistenceChange is called.
+            if (transition != null) {
+                addToSyncSet(transition.getSyncId(), taskFragment);
+            }
             // Set relative bounds instead of using setBounds. This will avoid unnecessary update in
             // case the parent has resized since the last time parent info is sent to the organizer.
             taskFragment.setRelativeEmbeddedBounds(creationParams.getInitialRelativeBounds());
-- 
GitLab