From c9853d9a63b1013f35c2441d3c2b99fb78c7b940 Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Fri, 12 Nov 2021 20:40:43 +0800 Subject: [PATCH] Release surface control of remote transition leash without removal Because the transition-leash is put under transition root, it will be removed with the root when the finish transaction executes. Otherwise if "transition-leash" is removed earlier than reparenting task to its original parent, it may show a few frames with empty root and looks flickering. Transition Root > transition-leash > Task > transition-leash > Task So it is enough to only release the reference. Bug: 206062800 Test: adb shell setprop persist.debug.shell_transit 1; reboot Launch app from home and return to home. The app and home should not flicker. Change-Id: I451f4bcce90405a6256ec40afd345824a79c96ae --- .../system/RemoteAnimationAdapterCompat.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java index 7729a7532f8f3..e84b552d65eb5 100644 --- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java +++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RemoteAnimationAdapterCompat.java @@ -205,20 +205,17 @@ public class RemoteAnimationAdapterCompat { @Override @SuppressLint("NewApi") public void run() { + counterLauncher.cleanUp(info.getRootLeash()); + counterWallpaper.cleanUp(info.getRootLeash()); + // Release surface references now. This is apparently to free GPU memory + // while doing quick operations (eg. during CTS). + for (int i = info.getChanges().size() - 1; i >= 0; --i) { + info.getChanges().get(i).getLeash().release(); + } + for (int i = leashMap.size() - 1; i >= 0; --i) { + leashMap.valueAt(i).release(); + } try { - counterLauncher.cleanUp(info.getRootLeash()); - counterWallpaper.cleanUp(info.getRootLeash()); - // Release surface references now. This is apparently to free GPU - // memory while doing quick operations (eg. during CTS). - for (int i = 0; i < info.getChanges().size(); ++i) { - info.getChanges().get(i).getLeash().release(); - } - SurfaceControl.Transaction t = new SurfaceControl.Transaction(); - for (int i = 0; i < leashMap.size(); ++i) { - if (leashMap.keyAt(i) == leashMap.valueAt(i)) continue; - t.remove(leashMap.valueAt(i)); - } - t.apply(); finishCallback.onTransitionFinished(null /* wct */, null /* sct */); } catch (RemoteException e) { Log.e("ActivityOptionsCompat", "Failed to call app controlled animation"