Scene.AnimationGroups dispose not removing them from array?

Ive got a setup where I need to dispose animation groups out of the scene once the assets using them are disposed.

Though in doing so noticed though that the items do not get removed from the scene.animationGroups after being deposed. Is this expected behavior?

When nodes get disposed they get dropped from the scene arrays, so I would assume animations groups as an Disposable should do the same?

I guess the work around would be to iterate though each group, splice it from the array, if it needs to be disposed then dispose it as the spliced ref and if not then push it back into the array?

Weird it should happen here: Babylon.js/animationGroup.ts at 5725fcd19d9a967404d35584570e71a46660a8a6 · BabylonJS/Babylon.js · GitHub

Can you provide a repro ?

I’m wondering if it has to do with them being imported from assetContainers. Let me see if I can reproduce in a PG.

Because I just checked with the normal setup yeah they dispose.

Interesting, ill have to dig deeper now.

Here is a partial example, not all the groups get removed for some reason. Id assume its the same causality.

You are iterating on a mutating array https://playground.babylonjs.com/#Z6SWJU#717

1 Like

Then i did not recreate it correctly, let me try again tomorrow.

I am using the Babylon unity toolkit so it might be something outside of bjs scope. Let me isolate the issue more.

1 Like

Its got to be something with what I’m doing with the toolkit, because even if I directly dispose them they stick around.

Thanks for your help though it has helped me isolate the things to look at now.

We fixed smthg for this in recent releases so you could try updating as well ?

1 Like