高通Camx 相机冷启动trace 分解
和你一起终身学习,这里是程序员Android
经典好文推荐,通过阅读本文,您将收获以下知识点:
一、Camx trace 调试开关设置
二、Camx 调试开关设置懒人脚本
三、Camera 冷启动阶段分解分析
一、Camx trace 调试开关设置
1.设置 camxoverridesettings trace开关
adb root
adb remount
adb shell "echo traceGroupsEnable=0x10080 >> /vendor/etc/camera/camxoverridesettings.txt"
adb shell "echo traceErrorEnable=TRUE >> /vendor/etc/camera/camxoverridesettings.txt"
adb shell "echo traceOutputEnable=0x10080 >> /vendor/etc/camera/camxoverridesettings.txt"
adb reboot
2. 重启后设置开启camx trace 开关
因为 camxoverridesettings 只有重启之后可以生效,所以重启完成后需要开启trace 开关,既可以开始抓取Camera的 Systrace。
adb shell "echo 1 > d/tracing/events/camera/enable"
二、Camx 调试开关设置懒人脚本
下面脚本主要用来设置Camx debug trace 开关的,内容如下:
#bin/bash
# setting camxoverridesettings prop
funSetCamxoverridesettings(){
adb shell "echo traceGroupsEnable=0x10080 >> /vendor/etc/camera/camxoverridesettings.txt"
adb shell "echo traceErrorEnable=TRUE >> /vendor/etc/camera/camxoverridesettings.txt"
adb shell "echo traceOutputEnable=0x10080 >> /vendor/etc/camera/camxoverridesettings.txt"
}
# setting CameraTrace prop
funEnableCameraTrace(){
adb shell "echo 1 > d/tracing/events/camera/enable"
}
# cat setting result
funCatCameraProp(){
echo "--------------------------------------------"
echo "please check Camera trace prop is set sucess"
echo "--------------------------------------------"
echo "camxoverridesettings prop :*****************"
adb shell cat /vendor/etc/camera/camxoverridesettings.txt
echo "tracing prop :******************************"
adb shell cat d/tracing/events/camera/enable
}
# it's only used in debug version
funRemountDevice(){
adb root
adb remount
if [ $? -eq 0 ]; then
echo "remount success"
funSetCamxoverridesettings
adb shell cat /vendor/etc/camera/camxoverridesettings.txt
for((i=0;$i<=10;i++))
do
sleep 1
echo "waring !!! the phone will reboot after $i s"
done
adb reboot
for((i=0;$i<=50;i++))
do
sleep 1
echo "waiting phone is reboot after $i s "
done
adb root
adb remount
funEnableCameraTrace
funCatCameraProp
else
echo "remount failed,please remount the devices"
fi
}
# main
funRemountDevice
echo "input any num exit "
read num
查看Camera 相关进程
测试后查看下Camera 相关进程,有助于后续Systrace 有选择的分析查看。
C:\Users\ProgramAndroid>adb shell ps | findstr camera
cameraserver 810 1 4396356 124740 0 0 S android.hardware.camera.provider@2.4-service_64
cameraserver 807 1 37792 3240 0 0 S vendor.oneplus.hardware.camera@1.0-service
cameraserver 1418 1 69628 11096 0 0 S cameraserver
system 6519 683 5221532 33168 0 0 S com.oneplus.camera.service
u0_a130 9163 683 6052676 46388 0 0 S com.oneplus.camera.pictureprocessing
system 10641 683 5594508 84672 0 0 S com.wingtech.cameraCalibration
u0_a138 12467 683 7046152 135544 0 0 S com.oneplus.camera
三、Camera 冷启动阶段分解分析
1. 从 TouchUp 到 ActivityStart 耗时
从Touch UP 到 ActivityStart 阶段,系统创建App进程耗时:
1.PostFork 耗时需要排查 Zygote.java 代码
Zygote.java frameworks\base\core\java\com\android\internal\os
2.ZygoteInit 耗时需要排查ZygoteInit.java 代码
ZygoteInit.java frameworks\base\core\java\com\android\internal\os
3.ActivityThreadMain耗时需要排查ActivityThread.java代码
ActivityThread.java frameworks\base\core\java\android\app
4.bindApplication 耗时需要排查ActivityThread.java代码,同上
2. 从 ActivityStart 到 App 层 OpenCamera 耗时
1. App 开始执行 MainActivity 一系列 onCreate,onStart,onResume,openCamera等操作
2.Framework层 cameraserver 开始响应App getCameraCharacteristics 、connectDevice 等操作。
camera Server 在此期间的行为
1.activityStart 耗时需要排查 LaunchActivityItem.java 代码
2.ResumeActivityItem耗时需要排查 ResumeActivityItem.java 代码
3.Choreographer#doFrame 耗时需要排查 Choreographer.java 代码
LaunchActivityItem.java frameworks\base\core\java\android\app\servertransaction
ResumeActivityItem.java frameworks\base\core\java\android\app\servertransaction
Choreographer.java frameworks\base\core\java\android\view
3.HAL 层 OpenCamera耗时
HAL 层开始响应 APP OpenCamera的操作,并返回 open状态 给APP。
Camera HAL OpenCamera 耗时
1.camera_module->open 耗时需要排查hal 层 CameraModule.cpp open 方法中的耗时
CameraModule.cpp hardware\interface\camera\common\1.0\default
4.APP 层 OpenCameraDone 到ConfigureStreams
5.HAL 层 ConfigureStreams 耗时
6. APP 层 ConfigureStreams Done 到 SetRepeatingRequests
7.SetRepeatingRequests 到 第一帧HAL3ProcessCaptureResult
8.HAL3ProcessCaptureResult 到第一帧Preview
9.Camera APP冷启动总耗时
友情推荐:
至此,本篇已结束。转载网络的文章,小编觉得很优秀,欢迎点击阅读原文,支持原创作者,如有侵权,恳请联系小编删除,欢迎您的建议与指正。同时期待您的关注,感谢您的阅读,谢谢!
点个在看,方便您使用时快速查找!