Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android UI not responding when loading larger GLB model #7956

Open
mbalajee opened this issue Jul 2, 2024 · 4 comments
Open

Android UI not responding when loading larger GLB model #7956

mbalajee opened this issue Jul 2, 2024 · 4 comments
Assignees
Labels
android Issue/feature request for Android only enhancement New feature or request gltf Specific to glTF support low priority Low priority issue

Comments

@mbalajee
Copy link
Contributor

mbalajee commented Jul 2, 2024

⚠️ Issues not using this template will be systematically closed.

Describe the bug
When loading larger models (over 8K entities) ModelViewer#loadModelGlb blocks the UI. Calling this function in a different thread results in This thread has not been adopted when executing ResourceLoader::Impl::computeTangents

Engine has been created from main thread so as per the below comment in Engine.cpp,

    // we're assuming we're on the main thread here.
    // (it may not be the case)
    mJobSystem.adopt();

only the thread from which the Engine is created will be adopted by the JobSystem which eventually blocks the UI when loading larger model

To Reproduce
Steps to reproduce the behavior:
Loading a larger model hangs the entire UI, can't exit out of the screen

Expected behavior
UI should not be blocked

Desktop (please complete the following information):

  • OS: Android
FEngine resolved backend: OpenGL
QUALCOMM build                   : 8e5405b, I57aaec3440
Build Date                       : 05/21/21
OpenGL ES Shader Compiler Version: EV031.32.02.10
Local Branch                     : mybranchebba1dbe-451b-f160-ac81-1458d0b52ae8
Remote Branch                    : quic/gfx-adreno.lnx.1.0.r135-rel
Remote Branch                    : NONE
Reconstruct Branch               : NOTHING
Build Config                     : S P 10.0.7 AArch64
Driver Path                      : /vendor/lib64/egl/libGLESv2_adreno.so
PFP: 0x016ee190, ME: 0x00000000
[Qualcomm], [Adreno (TM) 630], [OpenGL ES 3.2 V@0502.0 (GIT@8e5405b, I57aaec3440, 1621601959) (Date:05/21/21)], [OpenGL ES GLSL ES 3.20]

Smartphone (please complete the following information):

  • Device: OnePlus 6T/6GB RAM
  • OS: Android 11

Additional context
Sorry couldn't attach the glb file as it is confidential

@mbalajee
Copy link
Contributor Author

mbalajee commented Jul 2, 2024

UI is not blocked when I create the ModelViewer instance (& so the Engine instance) in Executors.newSingleThreadExecutor() & call modelViewer.render from the same executor. Is this the right way to unblock UI or is there a downside in creating ModelViewer in a non-main thread?

@mbalajee mbalajee changed the title Android UI not responding Android UI not responding when loading larger GLB model Jul 2, 2024
@mbalajee
Copy link
Contributor Author

mbalajee commented Jul 2, 2024

Oh when I back out of the screen I get this error,

Precondition
in shutdown:444
reason: Engine::shutdown() called from the wrong thread!

because ModelViewer destroys the view in addOnAttachStateChangeListener so I guess it is not as straightforward as operating modelViewer on a non-ui thread

@romainguy would you recommend maintaining a copy of ModelViewer ?

@pixelflinger pixelflinger added enhancement New feature or request android Issue/feature request for Android only gltf Specific to glTF support labels Jul 8, 2024
@pixelflinger pixelflinger added the low priority Low priority issue label Jul 8, 2024
@innolight
Copy link

@mbalajee we faced the same issue as you do. Are you aware of any workarounds for the issue?

@romainguy @pixelflinger this issue is blocking us from adopting this library in production. Do you have any suggestion for this performance issue?

@mbalajee
Copy link
Contributor Author

@innolight Yeah we ended up using Filament in a different thread from Android side. All calls to filament must be executed on the same thread. So UI is not blocked while Filament does its job initially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android Issue/feature request for Android only enhancement New feature or request gltf Specific to glTF support low priority Low priority issue
Projects
None yet
Development

No branches or pull requests

5 participants