From 80737bf6605b3e8600a9b6373d4824e5d04050fd Mon Sep 17 00:00:00 2001 From: Riddle Hsu Date: Mon, 5 Dec 2022 22:06:15 +0800 Subject: [PATCH] Defer creation of input sink surface until sync completes Currently with shell transition, isVisible() is true once visible is requested for launching activity. Then the input sink surface will be created when previous activity completes pause. But because the launching activity is in transition and the transaction is sync transaction, its surface operation is also deferred until the remote applies the sync transaction. In other words, the creation is too early and leads to lock contention such as blocking preparing starting window. With the sync state check, the timing of creating input sink surface will be similar as legacy transition, which is after the transition is ready, i.e. sync finished. That timing is usually less sensitive (contention) to transition latency. Bug: 260059642 Test: atest ActivityRecordInputSinkTests Test: Transition latency of OpenAppMicrobenchmark Change-Id: Id9719510c74296392e988abf8d48fe3af78026d3 --- .../core/java/com/android/server/wm/ActivityRecord.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index 66992aa79fc27..9c2ca976e19ce 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7444,8 +7444,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A } else if (!show && mLastSurfaceShowing) { getSyncTransaction().hide(mSurfaceControl); } - if (show) { - mActivityRecordInputSink.applyChangesToSurfaceIfChanged(getSyncTransaction()); + // Input sink surface is not a part of animation, so just apply in a steady state + // (non-sync) with pending transaction. + if (show && mSyncState == SYNC_STATE_NONE) { + mActivityRecordInputSink.applyChangesToSurfaceIfChanged(getPendingTransaction()); } } if (mThumbnail != null) {