While debugging the Linux Dead lock, I logged all the xmlHTTPRequest and found the same requests for some .gltf. Textures are loaded multiple times (requests with related allocations). Loaded but not uploaded to VRAM as there is a cache mecanism but too late in the loading pipeline.
So, some buffers are discarded but the request and loading is done in NativeEngine. I guess there is a cache mecanism in the browser to overcome this kind of issue. Maybe also the OS. But memory allocation and latency is a performance issue. Let alone bandwidth quota on mobile.
Fix proposal
Add a cache memory in xmlHTTPRequest with a configurable memory size
Add a cache in GLTFLoader to not load multiple times the same URL (I prefer this option as babylonjs will benefit as well)
Context
While debugging the Linux Dead lock, I logged all the xmlHTTPRequest and found the same requests for some .gltf. Textures are loaded multiple times (requests with related allocations). Loaded but not uploaded to VRAM as there is a cache mecanism but too late in the loading pipeline.
Pipeline
Textures found in the .gltf are loaded async in a buffer: https://github.com/BabylonJS/Babylon.js/blob/af28ff68fcf6f782f8dec7f0494d5fced8a2948f/loaders/src/glTF/2.0/glTFLoader.ts#L2020 and https://github.com/BabylonJS/Babylon.js/blob/af28ff68fcf6f782f8dec7f0494d5fced8a2948f/loaders/src/glTF/2.0/glTFLoader.ts#L2096
Then, this buffer is sent to the engine to create a texture with. But a texture cache discards that buffer if the URL is already present: https://github.com/BabylonJS/Babylon.js/blob/b8238023e50655c58361136a88fcd7e88f06772d/src/Materials/Textures/texture.ts#L371
So, some buffers are discarded but the request and loading is done in NativeEngine. I guess there is a cache mecanism in the browser to overcome this kind of issue. Maybe also the OS. But memory allocation and latency is a performance issue. Let alone bandwidth quota on mobile.
Fix proposal
ping @ryantrem