ARCore 通话记录

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

当您启用通话记录时,ARCore 将使用其 C API 名称记录所有 API 调用,无论构建应用时使用的是哪个 SDK 都是如此。您可以在 C API 参考文档中找到所有 C API 名称及其参数和返回值。

启用 API 通话记录

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

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

  1. 确保已安装 Google Play 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 相机预览图像应显示在设备屏幕上。

  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 相机预览图像应显示在设备屏幕上。

  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)