Scene Dispose Not Releasing All Meshes


#1

Yo @Deltakosh

When calling scene.dispose()… Empty meshes are NOT getting disposed and NOT getting the call to the onDispose observable. They even still show in the inspector. But meshes that have vertex data get disposed just fine.

I need all mesh nodes to be properly disposed of and is mesh.ondispose observable function to get called so i can clean up script component resource for those empty meshes as well.

Can you please take a look at that :slight_smile:


#2

Can you provide a repro on the playground? How do you create empty meshes?


#3

Here is my test:
https://www.babylonjs-playground.com/#B69RCY

You can see that “bye” is logged on the console


#4

Yo @Deltakosh

Well i noticed a few things… First tis scene is loaded via GLTF and in the inspector is shows the “Scene Controller” as a class of TransformNode.

But all objects or nodes in GLTF are parsed, created and assigned as BABYLON.Mesh
in the GLTF loadNodeAsync function.

That is where i assign the onDispose to the mesh before calling assign(babylonMesh)

So i am expecting all parsed nodes in scene will be BABYLON.Mesh … But that is apparently not the case. Something is make those BABYLON.Mesh classes into TransformNode classes that are not getting disposed.

Playground: Babylon.js Playground

The scene has a EMPTY MESH from Unity Export called “Scene Controller”

That is not even getting listed with newMeshes.


#5

Yo @Deltakosh … It seems that GLTF loader CONVERTS empty meshes to TransformNode class (as it shows in the inspector).

But when disposing scene… TransformNodes are not being disposed…

I also hope the onDispose observable i added to the BABYLON.Mesh before is magically gets converted to a TransformNode still fires off after you fix the NO TansformNodes being disposed when the scene gets disposed ?:slight_smile:


#6

Yep that is a bug!

I’ll make sure to fix it


#7

Fixed…will be in next commit

thank you sir!


#8

So how do you mark resolved in the new forums ???


#9

image