BabylonJS / BabylonReactNative

Build React Native applications with the power of Babylon Native
MIT License
371 stars 59 forks source link

Some glbs load slowly #72

Closed ryantrem closed 3 years ago

ryantrem commented 4 years ago

I haven't investigated this at all, only observed the issue and didn't want to lose track of it. For this model: https://raw.githubusercontent.com/microsoft/experimental-pcf-control-assets/master/surface.glb

Loading it in SceneForm directly is pretty much instantaneous. Loading it in Babylon React Native with JSC takes around 2 seconds. Loading it in Babylon React Native with Hermes takes around 5 seconds.

The above times are similar regardless of debug or release.

bghgary commented 4 years ago

This loads very fast on the web. I don't see anything in this model that will make it slow to load. The only thing I can think of that can be slow is the mipmap generation which should only be slow in debug.

ryantrem commented 4 years ago

Revising my numbers based on an actual release build instead of a debug build 🤦🏼‍♂️ (the numbers below are all on an iPhone X):

So in summary, load time is about double in Babylon Native compared to Babylon.js or directly in SceneKit. Not great, but not an order of magnitude, so I'd say this issue is lower priority than initially thought.

ryantrem commented 3 years ago

React Native's XMLHttpRequest takes the byte buffer, converts it to a base64 string, passes that string (by copy) to JavaScript, and finally it is converted in JavaScript back to a byte buffer. This is very slow. This has been addressed by allowing Babylon.js to use Babylon Native's XMLHttpRequest implementation instead of React Native's. See these PRs for details: