From c0cb4bbd2109eaa2d4fefecfb85926a62200cfc5 Mon Sep 17 00:00:00 2001 From: Mohamad Mahmoud Date: Mon, 21 Nov 2022 15:39:21 +0000 Subject: [PATCH] Move trace pruning after stack dumping Call maybePruneOldTraces after calling dumpStackTraces as it introduces unnecessary latency in some cases Test: Tested on a device Bug: 237671718 Change-Id: I54395c249e563d6ed445c5f1c974250ac26bafce --- .../java/com/android/server/am/ActivityManagerService.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 7d640772a4be4..6e7bd98322332 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -3492,9 +3492,6 @@ public class ActivityManagerService extends IActivityManager.Stub } final File tracesDir = new File(ANR_TRACE_DIR); - // Each set of ANR traces is written to a separate file and dumpstate will process - // all such files and add them to a captured bug report if they're recent enough. - maybePruneOldTraces(tracesDir); // NOTE: We should consider creating the file in native code atomically once we've // gotten rid of the old scheme of dumping and lot of the code that deals with paths @@ -3527,6 +3524,9 @@ public class ActivityManagerService extends IActivityManager.Stub if (firstPidEndOffset != null) { firstPidEndOffset.set(firstPidEndPos); } + // Each set of ANR traces is written to a separate file and dumpstate will process + // all such files and add them to a captured bug report if they're recent enough. + maybePruneOldTraces(tracesDir); return tracesFile; } finally {