Hello Fellow Babylon Developer,
I recently tried to load a 7mb base64 encoded glb file with babylon. The result was that it run out of memory the browser crashed and this happens all the time. When i just load the glb e.g via import which always fetches the entire thing it can load the model normally, this isn’t a solution though as i do have some binary data that i need to send with the model.
Now i load the model from webcache directly as base64 encoded as there seems to be no other way to load a glb from pure data.
Does anyone have an idea how i can possibly load the entire model? (No i can’t split it!)
I mainly need this so that the model is cached and doesn’t need to be reloaded everytime for like say a mobile user. I did read about the manifest files but they seem to not work correctly with a glb/gltf object.
I do not know much about GLB, but am good with process & have more experience than I often admit. More than likely running out of memory is related to a bug on your side.
True, processes sometimes need for very short periods of time need 2 copies of something, limiting the max size by 0.5. 7mb seems a little small to be triggering that alone though.
I advise making a base64 file from a small GLB. If that does not go through, you definitely have a bug. Otherwise, you might need to either or all:
- actively force no longer need stuff out of scope, to keep your memory footprint down.
- break up the file in sections, so as to keep the amount of memory needed at one time lower.
- Change your process of conversion.
Hmm current code is already pretty basic. Here a short list of the steps:
- Create Request
- Fetch Request
- Pass Data to Babylon.AppendAsync
So i’m not sure why it fails on such a tiny file like you said.
For 1. of your list there is nothing else besides the egine/secne that is activ in the scope.
2. is no possible as you can’t load a gltf partially e.g it’s one thing as also that would bloat the size probbably more as currently the gltf is draco compressed + in binary form e.g glb.
3. If i would know where to put the binary data or the u8 array that is the file in memory then i could do this but i’m not sure if that is even possible. I used the base64 steps only base the examples don’t show how one would do it with raw data.
The Easy solution to this problem is to use a service worker which chaches all of the scripts + glb files so that i never needs to be fetched again. I now do my modifications inside the worker and return babylon only the finished results…