一小时快速入门Android GPU Inspector

本文介绍如何使用 Android GPU Inspector (AGI) 对Android 应用进行系统性能分析帧性能分析 。面向熟悉Android图形的开发者。

  1. 待分析应用需要的前置条件
    (1) 将应用设置为可调试状态

    <application [...] android:debuggable="true">
    

    (2)如果应用使用 native Vulkan你还需要启用 Vulkan validation layers 。可以通过adb命令来启用

    app_package=<YOUR APP PACKAGE NAME HERE>
    abi=arm64v8a # Possible values: arm64v8a, armeabi-v7a, x86
    
    adb shell settings put global enable_gpu_debug_layers 1
    adb shell settings put global gpu_debug_app ${app_package}
    adb shell settings put global gpu_debug_layer_app com.google.android.gapid.${abi}
    adb shell settings put global gpu_debug_layers VK_LAYER_KHRONOS_validation
    

    在完成分析后,执行以下命令关闭该特性

    adb shell settings delete global enable_gpu_debug_layers
    adb shell settings delete global gpu_debug_app
    adb shell settings delete global gpu_debug_layers
    adb shell settings delete global gpu_debug_layer_app
    

    应用在启用Vulkan validation layers时,在进行性能分析之前,必须解决所有Vulkan validation相关的warning和error。

    (3)如果使用的是测试版GPU驱动程序,在 标签下添加以下元数据:

    <meta-data
              android:name="com.android.graphics.developerdriver.enable"
              android:value="true" />
    
  2. 设备验证
    AGI 需要兼容的 GPU 驱动程序。为了确保它提供有效的性能分析 AGI 会在您首次连接新设备时运行验证检查, 大约需要十秒钟通过检查后,您就可以使用该设备 来分析 Android 应用。

  3. 获取性能分析或者帧数据
    (1)启动 AGI,进行初始化设置。进入主界面
    在这里插入图片描述
    (2)点击 Capture a new trace, 系统会显示 Capture A New Trace 对话框中; 或者点击 Capture System Profile trace 按钮。选择过滤条件和选项,就可以抓取性能分析或者帧数据了。
    4. 分析数据
    点击 Open Trace,打开获取到的性能分析数据或者帧数据,然后就可以开始分析了。
    在这里插入图片描述
    在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值