google-ar / sceneform-android-sdk

Sceneform SDK for Android
https://developers.google.com/sceneform/develop/
Apache License 2.0
1.23k stars 604 forks source link

Blocking UI while loading a large 3D object from Asset folder #741

Open ntanduc2288 opened 5 years ago

ntanduc2288 commented 5 years ago

I have a 3D file (.sfb, size 30Mb) in the Assets folder, once I load it to memory by using these codes ModelRenderable.builder() .setSource(context, Uri.parse(productName)) .build() .thenAccept { productRenderable = it } .exceptionally { throwable -> throwable.message?.let { view.showMessage(it) } null } -> The view is hanging for a couple seconds (lagging).

I'd tried to put it in a background thread but I got this error "Must be called from the UI thread." -> it means we have to run that code on the main thread.

So how to prevent the lagging issue when loading 3D object to memory? Thank in advance!

JohnGilbertson commented 5 years ago

+1 to this.

We have several 3D assets that get loaded randomly when an augmented Image is detected, and having the whole app freeze for a couple of seconds when the new image is detected is a bad user experience.