Script tag for meshopt_decoder is getting added for every glb

I am not sure if this causes a repaint or not but definitely a memory/html node leakage issue. We are loading lots of glbs and this gets into the hundreds of script tags. I tried changing to a local copy of the decoder and that did not help. Any suggestions ?

1 Like

I see this isn’t a bug, digging in a little

let loadScriptAsync = function(url) {
    return new Promise((resolve, reject) => {
        let script = document.createElement('script');
        script.src = url;
        script.onload = () => {
            resolve();
        }
        document.head.appendChild(script);
    });
}

Maybe it would make sense to give this script tag an id like BABYLON_SCRIPT_(url to script) and check before adding the script tag if it exists and resolve if so ?

Adding @bghgary

This was fixed recently because of this forum post: EXT_meshopt_compression location (ES6) - Questions - Babylon.js (babylonjs.com)

What version of Babylon.js are you using?

Alpha 19 when I posted, have since moved to Alpha 20 and still there. I did see that other thread and changed to a local version of the decoder. That did not stop the tag from being added every time, just pointed src to the local copy in screenshot above.

Changing to a local version shouldn’t do anything. When you say you have moved to Alpha 20, what package is this for? The fix is in the @babylonjs/loaders package. If that’s not updated, it won’t have any effect.

1 Like

Thanks, all three were on alpha20 but I did not restart npm/webpack after ! All good now :slight_smile:

1 Like

Hey @bghgary I did not want to start a new thread for this but have a question.

On alpha20, I have to do this to stop the gltf_validator.js to stop being downloaded for every glb.

SceneLoader.OnPluginActivatedObservable.add(function (loader) {
    loader._validate = _.noop; // same as () => {}
})

doing this:

SceneLoader.OnPluginActivatedObservable.add(function (loader) {
    loader.validate = false
})

still has it downloading every glb ( not sure if then ignoring the validation false too )

am I doing something wrong there to prevent validation step ?

This wasn’t the case before alpha20?

I am not sure, I can jump back some versions and check. It’s something I just noticed was being downloaded every time

Are you using the inspector?

Can you try setting loader.validate to false and then checking loader.validate flag in an override loader._validate function and see if it is true or false?

We do have the inspector imported but not showing usually without a param on the url

SceneLoader.OnPluginActivatedObservable.add(function (loader) {
    loader.validate = false;
    loader._validate = () => {
        console.log("loader validate is" + loader.validate)
    }
})

It’s printing that loader.validate is true

The inspector code sets the validate to true explicitly which maybe it shouldn’t do. The glTF loader validate is off by default. My guess is that the inspector is setting the validate to true after your code.

2 Likes

Thank you again! Is there any harm in keeping the empty function override for now ?

No, that should be fine. Can you file an issue on GitHub?

Yep will do Importing inspector into es6 bundle overrides validate setting on SceneLoader · Issue #10343 · BabylonJS/Babylon.js · GitHub

1 Like