App
-
adb:适用于预估进程的启动时间范围
adb shell am start -W packagename 温启动
adb shell am start -S -W packagename 冷启动
- trace(perfetto) 适用于现场还在,可必现
-
ActivityMetricsLogger log 适用于线上埋点统计
-
120帧视频录像后数帧:适用于测试摸底,用户最直观体验(从手指抬起到第一帧出现)
- framework log:适用于有log
开始 | 结束 | |
启动process | Start proc | |
启动activity | START u0 | |
启动service | ActivityManager: *** startService | <<< DONE EXECUTING |
第1帧绘制完成时间点从这几种日志看:
- adb logcat |grep Displayed
- wm_activity_launch_time
- perfetto:Android App Startups metric
- perfetto:SF bufferQueue对应的App这一帧buffer被消费
System
adb logcat |grep SystemServerTiming
//SystemServer Service启动日志
adb logcat |grep ActivityManagerTiming
//AMS启动日志
adb logcat |grep StartActivityManager
//AMS启动时间
adb logcat -b events|grep boot_progress //Android init进程启动开始的各个阶段,如下所示:
01-01 08:00:05.347 409 409 I boot_progress_start: 5347
01-01 08:00:06.330 409 409 I boot_progress_preload_start: 6330
01-01 08:00:07.049 409 409 I boot_progress_preload_end: 7049
01-01 08:00:07.447 1096 1096 I boot_progress_system_run: 7447
01-01 08:00:08.106 1096 1096 I boot_progress_pms_start: 8106
01-01 08:00:08.180 1096 1096 I boot_progress_pms_system_scan_start: 8180
01-01 08:00:08.587 1096 1096 I boot_progress_pms_data_scan_start: 8587
01-01 08:00:08.589 1096 1096 I boot_progress_pms_scan_end: 8589
01-01 08:00:08.695 1096 1096 I boot_progress_pms_ready: 8695
01-01 08:00:09.679 1096 1096 I boot_progress_ams_ready: 9679
01-01 08:00:09.947 1096 1096 I car_helper_boot_phase: 600
01-01 08:00:10.538 1096 1265 I boot_progress_enable_screen: 10538
01-01 08:00:10.555 496 1611 I sf_stop_bootanim: 10555
01-01 08:00:10.555 1096 1265 I wm_boot_animation_done: 10555
boot_progress_start | init进程启动 |
USER Zygote Start | cat /sys/kernel/boot_kpi/kpi_values DRIVER Kernel Boot Done 等价于 boot_progress_preload_start |
wm_boot_animation_done | Android开机动画结束 |
系统启动阶段进程启动时机推荐使用bootchart查看:
Mac上生成Android BootChart
adb root
adb shell touch /data/bootchart/enabled
重启
adb shell
cd data/bootchart tar -zcf bootchart.tgz header proc_diskstats.log proc_ps.log proc_stat.log
adb pull data/bootchart/bootchart.tgz
java -jar bootchart.jar bootchart.tgz