Add tracepoint to track Launcher cold startup latency
We want this for the post-boot performance analysis as an
rough but easy to understand metric for time spent in post-boot.
Bug: 299342732
Test: Reboot phone, before lock screen start a trace
Test: Run the following SQL against the trace: select * from slice where name="LauncherColdStartup"
Change-Id: I8956368338b13cb059ba7086e74b4c7f25849be2
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 606b2c4..5b70264 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -324,6 +324,8 @@
private static final String DISPLAY_ALL_APPS_TRACE_METHOD_NAME = "DisplayAllApps";
public static final int DISPLAY_WORKSPACE_TRACE_COOKIE = 0;
public static final int DISPLAY_ALL_APPS_TRACE_COOKIE = 1;
+ private static final String COLD_STARTUP_TRACE_METHOD_NAME = "LauncherColdStartup";
+ public static final int COLD_STARTUP_TRACE_COOKIE = 2;
private static final FloatProperty<Workspace<?>> WORKSPACE_WIDGET_SCALE =
WORKSPACE_SCALE_PROPERTY_FACTORY.get(SCALE_INDEX_WIDGET_TRANSITION);
@@ -424,6 +426,7 @@
new CannedAnimationCoordinator(this);
private final List<BackPressHandler> mBackPressedHandlers = new ArrayList<>();
+ private boolean mIsColdStartupAfterReboot;
@Override
@TargetApi(Build.VERSION_CODES.S)
@@ -434,6 +437,14 @@
? COLD
: COLD_DEVICE_REBOOTING
: WARM);
+
+ mIsColdStartupAfterReboot = sIsNewProcess
+ && !LockedUserState.get(this).isUserUnlockedAtLauncherStartup();
+ if (mIsColdStartupAfterReboot) {
+ Trace.beginAsyncSection(
+ COLD_STARTUP_TRACE_METHOD_NAME, COLD_STARTUP_TRACE_COOKIE);
+ }
+
sIsNewProcess = false;
mStartupLatencyLogger
.logStart(LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION)
@@ -2820,6 +2831,11 @@
.logEnd(LAUNCHER_LATENCY_STARTUP_TOTAL_DURATION)
.log()
.reset();
+ if (mIsColdStartupAfterReboot) {
+ Trace.endAsyncSection(COLD_STARTUP_TRACE_METHOD_NAME,
+ COLD_STARTUP_TRACE_COOKIE);
+ }
+
MAIN_EXECUTOR.getHandler().postAtFrontOfQueue(
() -> getRootView().getViewTreeObserver()
.removeOnDrawListener(this));