Observer.remove() does not work consistently

Hi all,

I have found that calling observer.remove may or may not work.

Here is the repro:

The sphere should always stop when y position >= 2, but sometimes it just won’t stop.

On the other hand, calling observable.remove(observer) always works.

1 Like

It works this way - https://playground.babylonjs.com/#PGLSNH#3

You are totally right it looks like in some cases, deref gets Garbage Collected to early… I ll push a fix: Fix deref being GCed too early by sebavan · Pull Request #15909 · BabylonJS/Babylon.js · GitHub

cc @Deltakosh FYI

2 Likes

Thanks a lot for the report @s207152

Just bumped into this as well, Observable.remove() works fine but Observer.remove() doesn’t. Thank you for fixing this, hope we can get that released soon.

I think the fix is already included in 7.37.0. You may check it out. :grinning:

2 Likes

It is! I was loosing my mind over this for a while lol