Hello everyone!
When I load some ktx2 packed glb models with the babylonjs.loaders.js,I found that,for each glb model the loader will open a worker thread and load two js files from the server:
Then if the quantity of models gets larger the Chrome browser may crash!
Then I try to make some adjustments on the babylonjs.loaders.js’s GLTFValidation.ValidateAsync function:
This problem was dealt with temporarily,although the quesition still exist——is there a
formal approach to set the loader’s threads number,or is there a official threads pool to load models efficiently?
Another quesition is,What parameters do I need to adjust if I want to put all the models in the browser’s cache?So I can reload them from the hard disk with the 304 response code instead of download from web server.
Thank you for reading.
Hey there! I think the possible issue with having a pool of workers in the validation is that, if a worker was not available, we would have to wait for the load. I’m not sure if this would be desirable in the general case. But maybe we could add an option in the GLTF loader for a pool of workers, or even to skip the validation altogether? What do you think @sebavan@Evgeni_Popov ?
Do you have the inspector loaded? glTF validation should be off by default. The inspector code enables the validation if included.
KTX2, Draco, etc. both use the AutoReleaseWorkerPool which will automatically release the worker if idle for 1 second by default. Each can use up to 4 workers by default typically.
We can probably also do this for the validation, but it probably shouldn’t be running to begin with.
We can also maybe add a max total workers somewhere to ensure we don’t exceed a certain number of workers.
Thanks.You’re right!I exactly use the babylon.inspector.bundle.js in this program.When I remove the inspector the loading times of the blob becomes the same as the ktx2Decoder,and the gltf_validator.js won’t be load.
For the caching,I have tried as the doc,but I don’t know if I’m right.
First,I add “BABYLON.Database.IDBStorageEnabled = true;” in the code.Then I found the browser want to load for example the Tile_+000_+000-19-tc.glb.manifest?1674262066384 url.
So I create Tile_+000_+000-19-tc.glb.manifest with content:
“{
“version” : 1,
“enableSceneOffline” : true,
“enableTexturesOffline” : true
}”
Next,when I load this scene again,the response is :
The IDB support is only for .babylon format scenes and for textures, not for .glbs So if you want to cache glbs you’d have to have a separate solution. Maybe look into Using Service Workers - Web APIs | MDN (mozilla.org)?
Thank you for reply!
I have try as the doc you gave me.It seems like that,the babylon loader can treat the glb like a texture,and can load it from the hard disk.
But the question is,if I want to load more than one glbs,the loader can only cache the last glb offline.I have open an other question for this,could you do me a favour at there?