Scene.dispose() hangs

Hi,

just found one case when Scene.dispose() enters infinite loop, have to kill either script of browser - when scene contains a transform node that contains an instance!

Here’s what happens then in Scene.dispose():

    while (this.transformNodes.length) {
        this.transformNodes[0].dispose(true);
    }

That node becomes disposed, but is not removed from the transformNodes array, and this loop never ends.

I actually dispose() source to implement workaround:

  // CHECKME: WORKAROUND
  var i = 0;
  while (i < scene.transformNodes.length) {
    console.log("Disposing transformNode "+i+"/"+scene.transformNodes.length);
    if ( scene.transformNodes[i].isDisposed() ) {
      i++;
    }
    console.log(scene.transformNodes[i]);
      scene.transformNodes[i].dispose(true);
  }

To see the output, go to www.vrspace.org, choose avatar, choose the portal, look at javascript console.
The source is here: vrspace/avatar-selection.js at master · jalmasi/vrspace · GitHub

Hey can you repro in the PG? for some reasons I cannot repro this issue

Will try, may take some time though.

1 Like

Can’t repro that either. Been quite a while now, I suppose many things are different now.
Either way I did in PG exactly what I was doing locally, and everything seems fine.

Good news I guess :wink:

PG link - https://www.babylonjs-playground.com/#YB006J#339