Perfetto —— 靠谱的trace利器
最近踩到的坑,报了一个cst的测试项fail,帧率不符合预期,对应的测项进程是android.view.cts
肯定是要抓sytrace看看了
但是,试了systrace和atrace去抓,只抓了launcher的绘制,并没有android.view.cts的绘制信息
用-a指定app也是一样
经过实验,可以试下perfetto抓取(果然,google极力推荐使用还是没错的,要跟上工具的变化)
1、开启trace UI
am start com.android.traceur/com.android.traceur.MainActivity
需要开启开发者模式的,不然会打开闪退,因为对应的IAtrceService没有启动
settings put global development_settings_enabled 1
2、开启record trace,即可开始录制
3、复现场景
4、再次启动trace UI,关闭record trace
5、获取trace文件
/data/local/traces/
6、打开Perfetto UI ,加载trace文件分析
可以抓到cts的测项trace了
也可使用open with legacy UI,使用传统的systrace UI去分析trace,只是大小有限制,试过一百多M就直接报error,而perfetto仍然可以打开
备注:也可以用命令去抓,参考perfetto | Android 开发者 | Android Developers (google.cn),就是麻烦了点
Perfetto:
开启traced|traced_peobes进程
setprop persist.traced.enable 1
ps -ef | grep -E "traced|traced_peobes"
perfetto -o /data/misc/perfetto-traces/trace_log -t 120s -b 100mb -s 150mb sched freq idle am wm gfx view input
atrace:
atrace -t 10 -b 20480 gfx sched sync view input webview wm am hal res rs video -o /data/a.trace