From 806927c67cbb308739b06efe78ee474c83b66e24 Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Fri, 24 Jan 2025 05:37:23 +0000 Subject: DO NOT MERGE: Update ActivityRecordInputSink using the pending transaction In some cases where finishTransition happens before the pending transaction is applied, we can end up with a stale state. Subsequent prepareSurfaces does not fix the issue because the InputWindowHandle is only applied on changes. Fix the race by only using pending transactions to apply ActivityRecordInputSink state changes. Bug: 332277530 Test: POC from bug Flag: EXEMPT bug fix Change-Id: If93840ad7b2abbcb48c0c332870c48046c0f8fdc Merged-In: If93840ad7b2abbcb48c0c332870c48046c0f8fdc --- services/core/java/com/android/server/wm/Transition.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java index 2ac3125de961..6037fa55d78f 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -1240,16 +1240,15 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener { } // Update the input-sink (touch-blocking) state now that the animation is finished. - SurfaceControl.Transaction inputSinkTransaction = null; + boolean scheduleAnimation = false; for (int i = 0; i < mParticipants.size(); ++i) { final ActivityRecord ar = mParticipants.valueAt(i).asActivityRecord(); if (ar == null || !ar.isVisible() || ar.getParent() == null) continue; - if (inputSinkTransaction == null) { - inputSinkTransaction = ar.mWmService.mTransactionFactory.get(); - } - ar.mActivityRecordInputSink.applyChangesToSurfaceIfChanged(inputSinkTransaction); + scheduleAnimation = true; + ar.mActivityRecordInputSink.applyChangesToSurfaceIfChanged(ar.getPendingTransaction()); } - if (inputSinkTransaction != null) inputSinkTransaction.apply(); + // To apply pending transactions. + if (scheduleAnimation) mController.mAtm.mWindowManager.scheduleAnimationLocked(); // Always schedule stop processing when transition finishes because activities don't // stop while they are in a transition thus their stop could still be pending. -- cgit v1.2.3-59-g8ed1b