From 193cd61855b6e00a25d3fd8edbb485b2068afad0 Mon Sep 17 00:00:00 2001 From: wilsonshih Date: Mon, 13 Jan 2025 18:18:53 +0800 Subject: Skip writing item during shutdown process if the user is locked. Otherwise the persist thread would keep trying to write that item, may causing an infinite loop until timeout. Flag: com.android.window.flags.record_task_snapshots_before_shutdown Bug: 389571348 Test: run forrest with multi-user environment. Change-Id: Ifeefbba2aeff3a13790e8366c5ac34cd62b7fea5 --- services/core/java/com/android/server/wm/SnapshotPersistQueue.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/core/java/com/android/server/wm/SnapshotPersistQueue.java b/services/core/java/com/android/server/wm/SnapshotPersistQueue.java index a5454546341b..f30231934ca1 100644 --- a/services/core/java/com/android/server/wm/SnapshotPersistQueue.java +++ b/services/core/java/com/android/server/wm/SnapshotPersistQueue.java @@ -231,8 +231,13 @@ class SnapshotPersistQueue { if (next.isReady(mUserManagerInternal)) { isReadyToWrite = true; next.onDequeuedLocked(); - } else { + } else if (!mShutdown) { mWriteQueue.addLast(next); + } else { + // User manager is locked and device is shutting down, skip writing + // this item. + next.onDequeuedLocked(); + next = null; } } } -- cgit v1.2.3-59-g8ed1b