This issue is followed by:
The code to reproduce the bug is very short.
const canvas = document.createElement("canvas");
const engine = new Engine(canvas);
const scene = new Scene(engine);
new DefaultRenderingPipeline("default", true, scene);
scene.dispose();
engine.dispose();
After running the above code, the infinite setTimeout loop will run.
[image]
Here is the repository to reproduce the bug. I’ve kept the things minimal.
If you dispose the engine and scene immediately after creating them, the effect will wait …
Here’s the code to reproduce the bug
const canvas = document.createElement("canvas");
const engine = new Engine(canvas);
const scene = new Scene(engine);
const defaultPipeline = new DefaultRenderingPipeline("default", true, scene);
defaultPipeline.prepare(); // uncomment this line to fix the issue
scene.dispose();
engine.dispose();
You can see it’s running in an infinite setTimeout loop like this
Here is the code to reproduce the issue for debugging.
Contribute to noname0310/babylonjs-disposetest development by creating an account on GitHub.
Just in case you’re wondering if there’s any reason to write code to delete the engine as soon as it’s created.
I’m using babylon.js in react and I have some engine initialization code in useEffect callback where react’s strictmode is running a side effect twice and disposing of the first one.
This PR should fix the problem:
BabylonJS:master
← Popov72:fix-effect-infinite-loop
opened 08:43AM - 23 Sep 24 UTC
See https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose… -scene-with-defaultrenderingpipeline-again/53633
2 Likes