matrix-org / matrix-org/thirdroom
WebSG - disposal leak upon certain script errors
- Dominant language
- C
- Stars
- 647
- Forks
- 70
- PR merge metrics
- No merged PRs in 30d
Description
reproducing script:
```js
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.
Contributor guide
Research direction
Run the provided WebSG reproduction and observe the detached physics body after the script error and a world switch. Trace how nodes and physics bodies are owned and disposed during world changes; done means the body created before the error is disposed without requiring the node to be added to the scene.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- game-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100