# AfterWorldMatrixUpdate Observable issue with Babylon 5

**URL:** <https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178>\
**Category:** Bugs\
**Created:** [May 9, 2022, 1:43am UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178 "2022-05-09T01:43:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjythebee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/benjythebee/32/13587_2.png) [@Benjythebee](https://forum.babylonjs.com/u/Benjythebee)\
**Post date:** [May 9, 2022, 1:43am UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/1 "2022-05-09T01:43:53Z")

</div>

Babylon 5.5.5 has a new issue where onAfterWorldMatrixUpdateObservable combined with computeWorldMatrix() causes Maximum callstack;  
I found this previous post by @Evgeni_Popov which mentions that the maximum callstack is not supposed to happen.

> [@mesh.registerAfterWorldMatrixUpdate - Bug or Feature?](https://forum.babylonjs.com/t/mesh-registerafterworldmatrixupdate-bug-or-feature/8900/2):
>
> I don’t have an infinite recursion when calling getAbsolutePosition inside the registerAfterWorldMatrixUpdate callback: [https://playground.babylonjs.com/#KYLSMM](https://playground.babylonjs.com/#KYLSMM) I think you will need to provide a PG so that we can have a look.

The playground he uses is this one below (unchanged), and you’ll find that it does have infinite recursion with B5:

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

In my current application, when the player teleports we move a worldOffset transformNode with him/her so we can avoid z-fighting. To avoid sounds to follow the player we update the sound’s position to account for the worldOffset.

this means we end up with a code pattern very similar to that playground.

Is this an actual bug? Any tricks?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 9, 2022, 1:53pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/2 "2022-05-09T13:53:08Z")

</div>

@carolhmj do you want to have a look ?

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 2:27pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/3 "2022-05-09T14:27:00Z")

</div>



---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 2:27pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/4 "2022-05-09T14:27:06Z")

</div>

Will do!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 6:38pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/5 "2022-05-09T18:38:55Z")

</div>

Fix is here 🤣 [Fix a stupid bug by deltakosh · Pull Request #12504 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/12504)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 9, 2022, 6:38pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/6 "2022-05-09T18:38:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![Benjythebee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/benjythebee/32/13587_2.png) [@Benjythebee](https://forum.babylonjs.com/u/Benjythebee)\
**Post date:** [May 9, 2022, 7:27pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/7 "2022-05-09T19:27:47Z")

</div>

That was fast 😅, thanks!; Any ideas when next release is?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [May 9, 2022, 7:33pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/8 "2022-05-09T19:33:29Z")

</div>

You are the best @carolhmj 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [May 9, 2022, 8:45pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/9 "2022-05-09T20:45:14Z")

</div>

Should be live in a hour or 2:)

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 10, 2022, 12:51pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/10 "2022-05-10T12:51:31Z")

</div>

![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/3/f34857d1da675521f4dbd64538022f9e343a2eef.jpeg)

---

<div class="post-metadata">

**Author:** ![Benjythebee](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/benjythebee/32/13587_2.png) [@Benjythebee](https://forum.babylonjs.com/u/Benjythebee)\
**Post date:** [May 12, 2022, 1:54am UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/11 "2022-05-12T01:54:17Z")

</div>

We found this fix made our assets randomly nudged to the side after using `mesh.translate()` on local axes 😅

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/f/f/ff2ff7f8d69bdf9cbc9cf7be99eff6f63aed8f74.jpeg)

We’ll have a look at what’s causing it on our side, but a broad description of what the fix actually solves would help us look for where we got it wrong!

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [May 12, 2022, 12:24pm UTC](https://forum.babylonjs.com/t/afterworldmatrixupdate-observable-issue-with-babylon-5/30178/12 "2022-05-12T12:24:01Z")

</div>

You can see here on the file changes [Fix a stupid bug by deltakosh · Pull Request #12504 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/12504/files#diff-19548fe6a0feb27a51a0fd485c8c8b80d0bcb420434020981aaa9227349b2b63L1008), we previously had added an optimization to skip computing the world matrix if the renderId didn’t change, but the condition was flipped (a !== rather than a ===)

The initial change was added on 5.5.5, can you check 5.5.4 to see if your assets work there?
