ARCore 通话记录

对 Android 中的运行时行为和性能问题进行问题排查时 应用,您可以将 ARCore API 调用记录到 Android 设备日志

如果您启用通话记录,ARCore 将通过其 C API 记录所有 API 调用 无论应用是使用哪个 SDK 构建的。所有 C API 名称 C API 参考文档以及 其参数和返回值。

启用 API 调用日志记录

不接受 ArSession* 参数(例如 *_destroy)的 ARCore API 调用 和 *_release 函数。

请按照以下步骤启用 ARCore API 通话记录。

  1. 确保已安装 Google Play Services for AR (ARCore) 1.23 或更高版本:

    • 在 Windows 上,运行 adb shell pm dump com.google.ar.core | findstr /i "packages: versionName"
    • 在 macOS 上,运行 adb shell pm dump com.google.ar.core | egrep -i versionName\|packages:
  2. 在您的应用中打开 AR 体验,以便存在进行中的 ARCore 会话 。您的应用必须在 AR 模式下才能接收启用 AR 功能的广播 日志记录AR 相机预览图片应该在设备上可见 屏幕。

  3. 使用以下 activity 管理器广播命令启用通话记录: 。

    # Enables ARCore call logging and saves a setting to your app's
    # Android Shared Preferences, so that call logging remains enabled in
    # subsequent ARCore sessions.
    
    # Your app must have an actively running ARCore session to receive the broadcast.
    adb shell am broadcast -a com.google.ar.core.ENABLE_API_CALL_LOGGING
    

停用 API 调用日志记录

请按照以下步骤停用 ARCore API 通话记录。

  1. 在您的应用中打开 AR 体验,以便存在进行中的 ARCore 会话 。您的应用必须在 AR 模式下才能接收会停用 AR 功能的广播 日志记录AR 相机预览图片应该在设备上可见 屏幕。

  2. 使用以下 activity 管理器广播命令停用通话记录 :

    # Disables ARCore call logging and saves a setting to your app's
    # Android Shared Preferences, so that call logging remains disabled in
    # subsequent ARCore sessions.
    
    # Your app must have an actively running ARCore session to receive the broadcast.
    adb shell am broadcast -a com.google.ar.core.DISABLE_API_CALL_LOGGING
    

查看输出

ARCore 对所有 ARCore API 日志记录输出使用 ARCore-Api 标记。使用 以仅过滤这些调用。

# Currently, ARCore only logs API calls that take an `ArSession*` argument.
# Functions that do not take session parameters such as `*_destroy` and `*_release` are not logged.
# -s is equivalent to the filter expression '*:S', which sets priority for all tags to silent.

adb logcat -s ARCore-Api

ARCore 速率限制输出以减少垃圾日志。汇总跳过的日志 转换为单个日志消息。

跳过的日志消息的输出示例:

D ARCore-Api: ArFrame_create(<ptr>)
D ARCore-Api: ArSession_update(<ptr>) -> AR_SUCCESS
D ARCore-Api: ArFrame_acquireCamera(<ptr>, <ptr>)
D ARCore-Api: ArFrame_getDisplayGeometryChanged(<ptr>, <ptr>)
D ARCore-Api: ArCamera_getTrackingFailureReason(<ptr>, <ptr>)
D ARCore-Api: ArFrame_getTimestamp(<ptr>, <ptr>)
D ARCore-Api: ArSession_setDisplayGeometry(0, 1080, 2195)
D ARCore-Api: ArFrame_create(<ptr>) (suppressing for 10s)
D ARCore-Api: ArSession_update(<ptr>) -> AR_SUCCESS (suppressing for 10s)
D ARCore-Api: ArFrame_acquireCamera(<ptr>, <ptr>) (suppressing for 10s)
D ARCore-Api: ArFrame_getDisplayGeometryChanged(<ptr>, <ptr>) (suppressing for 10s)
D ARCore-Api: ArCamera_getTrackingFailureReason(<ptr>, <ptr>) (suppressing for 10s)
D ARCore-Api: ArFrame_getTimestamp(<ptr>, <ptr>) (suppressing for 10s)
D ARCore-Api: ArSession_setDisplayGeometry(0, 1080, 2195) (suppressing for 10s)