Load the viewer config in a background thread to minimize performance impact on process boot time
Bug: 354357871
Test: BootTimeTest.BootTimeTest#SuccessiveBootTest
Flag: android.tracing.perfetto_protolog_tracing
Change-Id: I9e06994a743acedb6f28bc4578d21856603bd803
diff --git a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
index 7d12d49..78b5cfe 100644
--- a/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
+++ b/core/java/com/android/internal/protolog/PerfettoProtoLogImpl.java
@@ -317,7 +317,11 @@
}
if (mViewerConfigReader != null) {
- mViewerConfigReader.loadViewerConfig(groupsLoggingToLogcat.toArray(new String[0]));
+ // Load in background to avoid delay in boot process.
+ // The caveat is that any log message that is also logged to logcat will not be
+ // successfully decoded until this completes.
+ mBackgroundLoggingService.execute(() -> mViewerConfigReader
+ .loadViewerConfig(groupsLoggingToLogcat.toArray(new String[0])));
}
}