arcore-android-sdk icon indicating copy to clipboard operation
arcore-android-sdk copied to clipboard

Native memory grows by between 10 and 30MB/min when ArSession_update is executed in a background thread

Open ptc-aeveritt opened this issue 3 years ago • 2 comments

SPECIFIC ISSUE ENCOUNTERED

VERSIONS USED

  • Android Studio: 2020.3.1 patch 4
  • ARCore SDK for Android: 1.23 and above (We have found this issue with 1.23, 1.24, 1.26, 1.28)
  • Device manufacturer, model, and O/S: Google Pixel 5, Samsung Galaxy Note9, Samsung Galaxy S21 +many others
  • Google Play Services for AR (ARCore): 1.28, 1.29 (these are the only versions we have available to test, the issue probably impacts all versions 1.23 and above) On Windows, use: adb shell pm dump com.google.ar.core | findstr /i "packages: versionName" On macOS, use: adb shell pm dump com.google.ar.core | egrep -i versionName\|packages: Pixel 5: 1.29.213210283 Note9: 1.29.213210223 GS21: 1.29.213210293
  • Output of adb shell getprop ro.build.fingerprint: Pixel 5: google/redfin/redfin:11/RQ3A.210805.001.A1/7474174:user/release-keys Note9: samsung/crownltexx/crownlte:10/QP1A.190711.020/N960FXXU9FUK1:user/release-keys GS21: samsung/o1quew/o1q:12/SP1A.210812.016/G991U1UES4BULE:user/release-keys

STEPS TO REPRODUCE THE ISSUE

  1. Take the computervision_c sample and modify it.
  2. In ComputerVisionApplication::OnResume create a thread, in the thread body create a GLES2 context, create an ArSession then start a loop calling ArSession_update. I can provide our modified version of the sample.
  3. Profile the modified App on device and observe memory growth

WORKAROUNDS (IF ANY)

None so far

ADDITIONAL COMMENTS

  • Looking at native heap samples the memory growth appears to come from libarcore_c.so
  • Memory growth is not observed if the ARCore SDK used in the App is 1.22, 1.20 or 1.18
  • We noted the documentation for ArSession_update say this "This call may cause off-screen OpenGL activity." but don't see any reason why we shouldn't be able to call the method from a thread instead of the draw callback. Our ARCore integration code was working fine until we moved to ARCore SDK 1.23 and higher.

ptc-aeveritt avatar Jan 20 '22 11:01 ptc-aeveritt

It would be great if you could add the repro so I can have a try; thanks.

devbridie avatar Jan 20 '22 12:01 devbridie

Hi - I have pushed changes to a fork of this repo, hopefully this will work for you. Please take a look at this branch - https://github.com/ptc-aeveritt/arcore-android-sdk/tree/bug/1338_memory_growth

While testing these changes I have noticed that with ARCore 1.22 (no memory growth) I get a new frame every update once the session has settled down at the start. Compare this with ARCore 1.29 (memory growth) where I see a significant proportion of updates where the frame timestamp does not move on.

ptc-aeveritt avatar Jan 20 '22 18:01 ptc-aeveritt