Creation of texture using a URL which has already caused failure will not trigger onError handler

Repro in playground:

When creating a Babylon texture by providing a image UR that would cause failure, most likely due to CORS policy, the first texture loaded will error out correctly so it can be handled accordingly by the client program. However if the same URL is used to create texture again, it would not trigger the onError handler since the _getFromCache call would result in a hit and the texture will not be re-created, and the on error handler cannot run either.

In the playground the second texture will trigger success callback but in SharePoint spaces we are not able to see either handler to run.

I think the cache hit should not happen if the previous texture creation has failed, but due to a variety of async process during texture creation I am reporting this as a bug to the Babylon team to see what’s the expected behavior, when a URL would fail, but another texture need to be created before its callback.

Keeping the texture in cache prevents extra errors when we are sure of the result but I agree it is less than convenient to catch errors :frowning:

@Deltakosh do you see any inconvenient to by passing the cache in case of error ? so that next load will generate an error as well ?

Checked with @Deltakosh offline, I ll remove the cache when in error.

This will be in the next release.

1 Like

PR is here Texture error when cached by sebavan · Pull Request #11217 · BabylonJS/Babylon.js · GitHub, it will be in the next nightly, I guess you want a new NPM @Haoxin_LIU ?

@sebavan there is no rush we can wait for the next rollout. With this new fix, if a second entity tries to load the same url before the url is removed from cache, will it be able to have its error handler invoked?
Basically, 2 images being loaded in the same scene at the same time, how can the second one know when to error out?

Yup it is the point of the fix, in your test scene both textures will be notified of the same error through the cached internal texture :slight_smile: