Skip to content

WebSG - disposal leak upon certain script errors #605

@NateTheGreatt

Description

@NateTheGreatt

reproducing script:

world.onenter = () => {
  const scene = world.environment;

  const boxNode = world.createNode({
    mesh: world.createBoxMesh({
      size: [1, 1, 1],
      segments: [1, 1, 1],
      material: world.createMaterial({
        baseColorFactor: [1, 1, 1, 1],
      }),
    }),
    collider: world.createCollider({ type: "box", size: [1, 1, 1] }),
  });
  
  boxNode.addPhysicsBody({ type: WebSG.PhysicsBodyType.Kinematic });

  // cause the script to error out before the node is added to the scene 
  boxNode.notAFunction();
  
  scene.addNode(boxNode);
};

By causing the script to error out before the node is added to the scene, a detached physics body is created that never gets disposed of, even when switching worlds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions