WEBGL - context lost

Hi there,
i have a problem babylon crashing.
i have a project wich uses deck.gl to load tiles from a tile Server according to camera position. It then generates the tiles and its materials.

interestingly i do run into this error when moving the camera quite fast and using big(er) textures (1024x1024px tiles)

as far as i understand, loosing the webgl context is not terrible, because it will restore the context once available again.

the problem here is (if i understand the errormessage correctly) that babylon tries to generate textures even if there is no webgl context. then the whole 3d viewer crashes and does not come back.

when i lower the resolution of the textures the problem does not accure. How can i try to solve that issue or how can i figure out what causes the webGL context loss?

any idea would be great!

Thanks a lot!

not necessarily, here you encountered a pretty big driver crash

several times in a row so you might not recover any contexts after this.

It looks like you are running out of vram :frowning: so reducing the asset size or reusing would be the way to go.

1 Like

Hi thank you so much!! i was looking at the RAM (not vram) and could not find anything suspicious.
The vram really runns full. lets try and find disposable stuff :wink:


Hi there, i think i have found the Problem. when i dispose the tiling meshes, the textures do not get disposed. Is that normal?

 onTileUnload: async (tile) => {

        console.log("onTileUnload", this.scene?.meshes.filter((mesh) => mesh.name === tile.id).length)
        this.scene?.meshes.filter((mesh) => mesh.name === tile.id)?.map((m) => {
          m.material?.getActiveTextures().map((t) => t.dispose())


the problem does not accure anymore when i add this …getActiveTextures() line. Is this a behaviour wich is expected? Until now i thought that textures get disposed when they are not on a material anymore?

Thanks for clarification!!


Textures could be shared so not disposed by default.

You can force dispose them in PBR by setting the second parameter of the dispose function to true.