From d07e2cfe83479332fdf618d6523402a4a1f634c4 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 --- 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 db8079a9cd2f..32b006d00b3c 100644 --- a/services/core/java/com/android/server/wm/Transition.java +++ b/services/core/java/com/android/server/wm/Transition.java @@ -836,16 +836,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 = new SurfaceControl.Transaction(); - } - 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