# \`Effect.\_checkIsReady\` infinite loop when dispose scene with DefaultRenderingPipeline

**URL:** <https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112>\
**Category:** Bugs\
**Tags:** engine\
**Created:** [July 17, 2024, 2:21am UTC](https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112 "2024-07-17T02:21:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![noname0310](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/noname0310/32/27103_2.png) [@noname0310](https://forum.babylonjs.com/u/noname0310)\
**Post date:** [July 17, 2024, 2:21am UTC](https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112/1 "2024-07-17T02:21:04Z")

</div>

The code to reproduce the bug is very short.

```typescript
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](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/9/9/99ba9be84db88bfe5d4282b884d1ecbbc8f3e068.png)

Here is the repository to reproduce the bug. I’ve kept the things minimal.

> **[GitHub - noname0310/babylonjs-disposetest](https://github.com/noname0310/babylonjs-disposetest)**
>
> Contribute to noname0310/babylonjs-disposetest development by creating an account on GitHub.

If you dispose the engine and scene immediately after creating them, the effect will wait indefinitely for shader compilation.

However, without DefaultRenderingPipeline, this bug does not occur. 🙄

The bug seems to be related to this issue.

> [@Disposing a scene before effects are ready creates memory leak and infinite setTimeout](https://forum.babylonjs.com/t/disposing-a-scene-before-effects-are-ready-creates-memory-leak-and-infinite-settimeout/30768):
>
> This is another one I have stumbled across while looking at memory leaks in our [app](https://www.spotvirtual.com). Looks like there is an infinite setTimeout loop that fails to stop if the scene becomes disposed. Looks like it is originating here: [Babylon.js/effect.ts at master · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/master/packages/dev/core/src/Materials/effect.ts#L573) Maybe we could check for isDisposed in there as well?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 17, 2024, 3:05pm UTC](https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112/2 "2024-07-17T15:05:08Z")

</div>

Let me check that 🙂

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [July 17, 2024, 3:36pm UTC](https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112/3 "2024-07-17T15:36:28Z")

</div>

here we are:  
[Fix effect dispose memory leak by deltakosh · Pull Request #15294 · BabylonJS/Babylon.js (github.com)](https://github.com/BabylonJS/Babylon.js/pull/15294/files)

---

<div class="post-metadata">

**Author:** ![noname0310](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/noname0310/32/27103_2.png) [@noname0310](https://forum.babylonjs.com/u/noname0310)\
**Post date:** [July 17, 2024, 11:08pm UTC](https://forum.babylonjs.com/t/effect-checkisready-infinite-loop-when-dispose-scene-with-defaultrenderingpipeline/52112/4 "2024-07-17T23:08:03Z")

</div>

Thank you always 🙂 🙂 🙂
