CubeTexture onError callback not called

Hi
I’m using the CubeTexture function (in combination with a promise) and it seems that the onError callback is not called if you try to load the same (broken) texture again.
Not sure if this is a bug of if I’m doing something wrong.

const url = 'broken texture.env';
await loadCubemapTest(scene, url);
await loadCubemapTest(scene, url);
...
async function loadCubemapTest(scene, url) {
    console.log('start loading ...');
    return new Promise((resolve, _reject) => {
        try {
            let tex;
            tex = new BABYLON.CubeTexture(url, scene, [], false, [],
                () => {
                    console.log("--> loaded");
                    resolve(tex);
                },
                (message, exception) => {
                    console.log("--> loading error");
                    resolve();
                }
            );
        } catch(e) {
            console.log("--> loading error catch");
            resolve();
        }
    })
}

Playground:

This is because of the way babylon caches URL requests. Try this:

Changing the URL (adding a quesry string) will result in a second network request

Thx for you help.
Is this the expected behaviour?
I mean wouldn’t it make sense that the onError callback is also called in this case? :thinking:

yeah, that’s a good question :slight_smile:
I’m acually still thinking about it, will get back to you on this one.

1 Like

Any update here? :upside_down_face:

Oh, sorry! I was on it and then went away.
Yes, this should throw an error, but it is such a specific case that I need to find the right way to fix it. Will get back to you on this one! sorry for the delay

1 Like

Update! :slight_smile:

2 Likes

nice. Thank you :slight_smile:

1 Like