Crash on Chrome and BJS 4.1 - caused by WATER MATERIAL and something else

Edit: Following error is caused by WaterMaterial, once I removed it, it started to work - but error occured later - I will test what other thing causes it but apparently WaterMaterial is one of them.

Hello, I came back to my game development after several months. I have noticed that BJS 4 stopped to work on Chrome at all. I was advised to upgrade into 4.1. and so I have done.

But now I see another error - it is different than the previous one, but It does not tell me anything usefull :-/ Someone noticed similar issue ? It is working on FF and IE (with some minor issues but it is at least working).

Chrome show following error which I dont understand sadly :frowning:
Note: Nothing is rendered on the screen, it is all black.

babylon4-1.js:16 Uncaught TypeError: Cannot read property ‘0’ of undefined
at e.getAttributeLocation (babylon4-1.js:16)
at t.e._bindVertexBuffersAttributes (babylon4-1.js:16)
at t.e.recordVertexArrayObject (babylon4-1.js:16)
at e._bind (babylon4-1.js:16)
at t._bind (babylon4-1.js:16)
at t.render (babylon4-1.js:16)
at t.render (babylon4-1.js:16)
at Function.e.renderSorted (babylon4-1.js:16)
at e.renderTransparentSorted (babylon4-1.js:16)
at e.render (babylon4-1.js:16)

Thanx for your insight.

1 Like

I’m having a similar problem using the latest stable version of BabylonJs (not minified), may or may not be related to WaterMaterial:

effect.ts:426 Uncaught TypeError: Cannot read property '0' of undefined
at Effect../Materials/effect.ts.Effect.getAttributeLocation (effect.ts:426)
at Engine../Engines/engine.ts.Engine._bindVertexBuffersAttributes (engine.ts:2755)
at Engine../Engines/engine.ts.Engine.recordVertexArrayObject (engine.ts:2801)
at Geometry../Meshes/geometry.ts.Geometry._bind (geometry.ts:376)
at Mesh../Meshes/mesh.ts.Mesh._bind (mesh.ts:1298)
at Mesh../Meshes/mesh.ts.Mesh._renderWithInstances (mesh.ts:1452)
at Mesh../Meshes/mesh.ts.Mesh._processRendering (mesh.ts:1466)
at Mesh../Meshes/mesh.ts.Mesh.render (mesh.ts:1644)
at SubMesh../Meshes/subMesh.ts.SubMesh.render (subMesh.ts:307)
at RenderingGroup../Rendering/renderingGroup.ts.RenderingGroup.renderUnsorted (renderingGroup.ts:244)
at RenderingGroup../Rendering/renderingGroup.ts.RenderingGroup.render (renderingGroup.ts:124)
at RenderingManager../Rendering/renderingManager.ts.RenderingManager.render (renderingManager.ts:158)
at Scene../scene.ts.Scene._renderForCamera (scene.ts:3518)
at Scene../scene.ts.Scene._processSubCameras (scene.ts:3539)
at Scene../scene.ts.Scene.render (scene.ts:3801)
at playstate.js:448
at Engine../Engines/engine.ts.Engine._renderLoop (engine.ts:1982)

The error for my case depends on the time it takes to reach the first render call. If I prolong the time to first render call, e.g. by loading 10 to 100 assets first and starting render loop only after all assets are loaded by the taskmanager, the probability of the error happening decreases. The error therefore seems to happen randomly based on some load state, because without a code change the rendering sometimes works and sometimes not. When the error happens then rendered on the screen at the moment are some meshes but never the ground mesh (which may include water material).

Hello unfortunately sharing only the error does not help. We need a repro in the playground to help you understand the root cause

1 Like

@Deltakosh Compared to @stealman I haven’t been able to isolate the error yet (e.g. “when I remove the watermaterial then no error”). The error happens in my case semi-random based on loading speed. So probably some mesh or material or texture isn’t fully initialized/loaded by the time the scene starts rendering.

Is there a smart way / option in my browser to get the object stack (or something similar) when the crash occurs? So that I can debug which mesh or material it was trying to draw when the error occurred?

You can use babylon.max.js and set chrome to stop on all exceptions. This should let you precisely know where the issue starts

Thanks! I’m using babylon.max.js already and will figure out how to stop chrome on all exceptions (haven’t done that before). When I found something I post a new reply to this topic.

It is interesting to note that when the rendering error occurs, and thus the execution stops before of Javascript error, after that when I manually call scene.render() from the console then the drawing goes fine without error. So I’m getting the idea that Babylon.JS rendering code assumes something (like a material) to be loaded but when it isn’t (yet) then no assertion is done before trying to execute that code.

The ultimate error happens when _attributes is undefined, so maybe you could do some debugging in there:

I am not sure but it can be a problem with the graphic driver. I am facing the same issue.
I have to use taskill/chrome.exe to check the results.

Hello, I am back after some time … I agrree with Gijs, that error occurs at getAttributeLocation - here is complete stack that I see in chrome. It is working ok in Firefox.

Sadly that WaterMaterial didnt cause the problem, I thought it was, but it did not. I have no idea where the problem is :frowning:

at e.getAttributeLocation (babylon4-1.js:16)
at t.e._bindVertexBuffersAttributes (babylon4-1.js:16)
at t.e.recordVertexArrayObject (babylon4-1.js:16)
at e._bind (babylon4-1.js:16)
at t._bind (babylon4-1.js:16)
at t._renderWithInstances (babylon4-1.js:16)
at t._processRendering (babylon4-1.js:16)
at t.render (babylon4-1.js:16)
at t.render (babylon4-1.js:16)
at e.renderUnsorted (babylon4-1.js:16)

We are going to need a repro to move the needle here

Well I will try to isolate and reproduce the cause and I will let you know then.

1 Like

Not a repro but this had happened to me yesterday.

The issue was with materials. I built a tool that lets me easily reuse materials based on the properties of the materials - all materials are automatically cloned if matching material is found - but I can control this by passing reuseMaterial: false to my mesh builder.

I removed this from my bullet creator by mistake and it started happening, if I add it back (each bullet gets a new material) it starts working just fine.

So I would check if you are maybe cloning materials and disposing them somehow, while trying to use them elsewhere?