การบันทึกการโทรของ ARCore

เมื่อแก้ปัญหาเกี่ยวกับการทำงานและปัญหาด้านประสิทธิภาพขณะรันไทม์ในแอป Android คุณสามารถบันทึกการเรียก ARCore API ไปยังบันทึกของอุปกรณ์ Android ได้

เมื่อคุณเปิดใช้การบันทึกการโทร ARCore จะบันทึกการเรียก API ทั้งหมดที่มีชื่อ API ของ C โดยไม่คำนึงถึง SDK ที่สร้างด้วยแอป ดูชื่อ API ของ C ทั้งหมดได้ในเอกสารอ้างอิงเกี่ยวกับ C API พร้อมพารามิเตอร์และค่าที่แสดงผล

เปิดใช้การบันทึกการเรียก API

ระบบจะไม่บันทึกการเรียก ARCore API ที่ไม่ได้ใช้พารามิเตอร์ ArSession* เช่น ฟังก์ชัน *_destroy และ *_release

ทำตามขั้นตอนต่อไปนี้เพื่อเปิดใช้การบันทึกการโทรของ 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. ใช้คำสั่งประกาศของเครื่องมือจัดการกิจกรรมต่อไปนี้เพื่อเปิดใช้การบันทึกการโทรสำหรับแอปของคุณ

    # 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. ใช้คำสั่งประกาศของเครื่องมือจัดการกิจกรรมต่อไปนี้เพื่อปิดใช้การบันทึกการโทรสำหรับแอปของคุณ

    # 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)