Exception: Uncaught Error: Unable to create texture at e._createTexture

Got thousands of exception for Uncaught Error: Unable to create texture at e._createTexture,
Uncaught Error: Cannot load cubemap because files were not defined at r.B.createCubeTexture
but can’t not see any error from console or from the UI, looks like it’s some method from babylon, if anyone know what can cause this exception? Thanks

Can you repro in the playground ?

This could normally happen only if the gl context is in a bad state or was not created.

It does not have any error in console, everything works fine with our UI, and we can only get that from our telemetry, so I can’t reproduce it, could you give some suggestion about where can we look at?

You should hook some telemetry in the context lost event to see if the other errors are subsequent to it or not.

I took a look, only this error happens, there is no other error happens after that

Error: Unable to create texture
at e._createTexture
at new e
at i.B.createDynamicTexture
at t [as constructor]
at new t
at t.CreateFullscreenUI

This method is called when creating a gui

are you passing a scene into CreateFullscreenUI and if yes, try to listen to context lost to see if you detect it as it would not log an error by default.

Yes, this is what I use
let texture = AdvancedDynamicTexture.CreateFullscreenUI(“gui”, true, scene);

Could you explain more about “try to listen to context lost to see if you detect it as it would not log an error by default.”

use attachContextLostEvent on engine to add a callback if this happens. In this callback log an error so that you know if the rest of your issues are related to this.

if yes you probably have a memory leak somewhere. if no, either there is a glitch in your code, like the the scene you pass in is not the expected one or the texture is created before the scene.

This is almost impossible for us to help more on this one without a repro :frowning:

1 Like

We found we already caught WEBGLCONTEXTLOST in my telemetry, it did caused by that

1 Like

Hi @sebavan ,

Is there any hotfix we can do for webglcontextlost?

This usually indicates a memory leak which is mostly related to your code not releasing memory you are allocating on the gpu.

1 Like

we are coming across this exact same error, and end up loosing webgl context. Are there any best practices to releasing memory as it relates to babylonjs. ?

@Anupam_Das it really looks like you have a memory leak in your app which could be coming from within Babylon.

Would be amazing to have a repro we could have a look into.