排解 Android 應用程式的執行階段行為和效能問題時,您可以將 ARCore API 呼叫記錄至 Android 裝置記錄。
當您啟用呼叫記錄功能,ARCore 就會使用本身的 C API 名稱記錄所有 API 呼叫,無論應用程式建構使用的 SDK 為何。您可以在 C API 參考說明文件中找到所有 C API 名稱、名稱及傳回值。
啟用 API 呼叫記錄功能
不使用 ArSession*
參數 (例如 *_destroy
和 *_release
函式) 的 ARCore API 呼叫則不會記錄。
請按照下列步驟啟用 ARCore API 呼叫記錄功能。
確認已安裝 ARCore (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:
。
- 在 Windows 上執行
在應用程式中開啟 AR 體驗,讓 ARCore 工作階段正在執行中。您的應用程式必須在 AR 模式下,才能接收啟用記錄功能的廣播訊息。AR 相機預覽圖片應會顯示在裝置螢幕上。
請使用以下活動管理員廣播指令,為應用程式啟用通話記錄:
# 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 呼叫記錄。
在應用程式中開啟 AR 體驗,讓 ARCore 工作階段正在執行中。您的應用程式必須在 AR 模式下才能接收停用記錄功能的廣播訊息。AR 相機預覽圖片應會顯示在裝置螢幕上。
使用以下活動管理員廣播指令,停用應用程式的通話記錄:
# 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)