google-ar / arcore-android-sdk

ARCore SDK for Android Studio
https://developers.google.com/ar
Other
4.91k stars 1.2k forks source link

WebView performance substantially impacted when ARCore is in the same app #1653

Open michaeltheory opened 1 month ago

michaeltheory commented 1 month ago

SPECIFIC ISSUE ENCOUNTERED

I am working on a prototype of rendering AR content with WebGL in a WebView in order to support features that WebXR does not yet support. It works perfectly on iOS, but on Android as soon as an ARCore session is created, the WebView framerate drops in half.

I have built the app up carefully with a number of steps. First I set up OpenGL in a custom SurfaceView to avoid compositing GLSurfaceView with WebView. Rendering a transparent WebView on top of a very simple OpenGL scene had no performance impact.

As soon as I initialize a Session the browser framerate drops in half.

I tried to initialize the Session in a thread, and re-wrote the app to accommodate that, but the result is the same. This seems like a bug.

Is there something I can do differently to achieve my desired result, or is this a bug?

VERSIONS USED

STEPS TO REPRODUCE THE ISSUE

  1. Outlined above

WORKAROUNDS (IF ANY)

None

ADDITIONAL COMMENTS

15kingben commented 1 month ago

Is the ARCore Session setting Target FPS 30 or 60? Note that 60FPS was previously disabled, but that should be fixed if the device has Android 14. You could also try changing the Config.UpdateMode from BLOCKING to LATEST_CAMERA_IMAGE

michaeltheory commented 1 month ago

I just set it to 30 and I have always been using LATEST_CAMERA_IMAGE, same result. When I use BLOCKING the browser gets really bad. I can send you this apk if you'd like? It's a pretty isolated example of just what I've described

kinjalbhavsar commented 1 month ago

For comparison, can you please share the framerate with and without the ARCore session?

michaeltheory commented 1 month ago

For comparison, can you please share the framerate with and without the ARCore session?

It runs at 80-85fps without Session and 48-52fps with. This is a Pixel 7