# \[Error\] \`this.\_attributes is undefined\`

**URL:** <https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106>\
**Category:** Bugs\
**Created:** [August 8, 2023, 2:03pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106 "2023-08-08T14:03:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Sosnovskiy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexander_sosnovskiy/32/30165_2.png) [@Alexander\_Sosnovskiy](https://forum.babylonjs.com/u/Alexander_Sosnovskiy)\
**Post date:** [August 8, 2023, 2:03pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/1 "2023-08-08T14:03:15Z")

</div>

Babylon: 6.7.0  
Devices: Desktop  
Browsers: Firefox 78,102,112,114, 115, 116 and others

I see the error in the particle system. I’m using GPUParticleSystem.

I have two kind of PS - code-based and from the snippet. But unfortunately, I can’t tell you which one with this issue(maybe both).

**TypeError: this.\_attributes is undefined**

```auto
at e.prototype.getAttributeLocation
at e.prototype._bindVertexBuffersAttributes
at e.prototype.recordVertexArrayObject
at e.prototype._createUpdateVAO
at e.prototype.createVertexBuffers
at t.prototype._createVertexBuffers
at t.prototype._initialize
at t.prototype.render 
at e.prototype._renderParticles
at e.prototype.render
at e.prototype.render
at t.prototype._renderForCamera
at t.prototype._processSubCameras 
at t.prototype.render
...
at t.prototype._renderFrame 
at t.prototype._renderLoop

```

I have similar stack trace on others devices(Mobile Chrome 89.0.4389, Tablet Chrome 87.0.4280 …):

**TypeError: Cannot read properties of undefined (reading ‘0’)**

```auto
  at e.getAttributeLocation [js/babylon-6_7_0.js:1:238409]
  at e._bindVertexBuffersAttributes [js/babylon-6_7_0.js:1:315516]
  at e.recordVertexArrayObject [js/babylon-6_7_0.js:1:316246]
  at e._createUpdateVAO [js/babylon-6_7_0.js:1:3722062]
  at e.createVertexBuffers [js/babylon-6_7_0.js:1:3718697]
  at t._createVertexBuffers [js/babylon-6_7_0.js:1:3821078]
  at t._initialize [js/babylon-6_7_0.js:1:3823676]
  at t.render [js/babylon-6_7_0.js:1:3834246]
  at e._renderParticles [js/babylon-6_7_0.js:1:448080]
  at e.render [js/babylon-6_7_0.js:1:444174]

```

I found this line where \_attributes has been assigned: [https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Materials/effect.ts#L784](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Materials/effect.ts#L784)

Seems like I start PS before it’s ready…

I see `this._initialize()` [https://github.com/BabylonJS/Babylon.js/blob/8a42ad80d4419c668120f5eedac9be6a2b8f5a3a/packages/dev/core/src/Particles/gpuParticleSystem.ts#L1671](https://github.com/BabylonJS/Babylon.js/blob/8a42ad80d4419c668120f5eedac9be6a2b8f5a3a/packages/dev/core/src/Particles/gpuParticleSystem.ts#L1671) only on GPUParticleSystem.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 8, 2023, 2:30pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/2 "2023-08-08T14:30:14Z")

</div>

Assigned @Evgeni\_Popov on August 8, 2023, 2:30pm UTC



---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 8, 2023, 3:37pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/3 "2023-08-08T15:37:34Z")

</div>

Given your stack trace, I tried to reproduce the problem, but was unable to.

Accessing `_attributes` when it is not initialized can happen if `_createUpdateVAO` is called with an effect that is not yet ready. In this case, the effect is `_updateEffect`, but `_initialize` (and therefore, `_createUpdateVAO`) can only be called if `_updateEffect` is ready. At least, that’s what happens in my tests…

What you could test is to set `engine.getCaps().parallelShaderCompile = null` and see if that helps. This will force the shader compilation to be synchronous.

If you’re able to set up a repro, that would be a big help.

[…] I have been able to reproduce the problem when simulating a context lost!

This PR will fix the bug (hoping your problem stems from a context lost indeed!):

> <https://github.com/BabylonJS/Babylon.js/pull/14135>
>
> See https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106

However, if you use your own particle effect from a node material, you have to recreate the effect when the context is restored.

Here’s how to do it:

> **[Babylon.js Playground](https://playground.babylonjs.com/#J9J6CG%2377)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 8, 2023, 3:37pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/4 "2023-08-08T15:37:38Z")

</div>

Unassigned @Evgeni\_Popov on August 8, 2023, 3:37pm UTC



---

<div class="post-metadata">

**Author:** ![Alexander\_Sosnovskiy](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alexander_sosnovskiy/32/30165_2.png) [@Alexander\_Sosnovskiy](https://forum.babylonjs.com/u/Alexander_Sosnovskiy)\
**Post date:** [August 8, 2023, 3:52pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/5 "2023-08-08T15:52:08Z")

</div>

Right now I replaced GPU PS to CPU PS 😁 But yeah, thank you for a possible test case. I’ll try to reproduce it.

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [August 8, 2023, 4:47pm UTC](https://forum.babylonjs.com/t/error-this-attributes-is-undefined/43106/6 "2023-08-08T16:47:43Z")

</div>

> [@Alexander\_Sosnovskiy](#):
>
> I’ll try to reproduce it.

You may not have, if the fix fixes it.
