# scene.whenReadyAsync not firing

**URL:** <https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667>\
**Category:** Bugs\
**Created:** [May 24, 2022, 2:17am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667 "2022-05-24T02:17:48Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![waverider404](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waverider404/32/17464_2.png) [@waverider404](https://forum.babylonjs.com/u/waverider404)\
**Post date:** [May 24, 2022, 2:17am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/1 "2022-05-24T02:17:48Z")

</div>

after the recent update to v5.7.0, i noticed that scene.whenReadyAsync is not firing, likewise scene.executeWhenReady doesnt work in other files, i had to do scene.whenReadyAsync(null) in the index.js for the function to work in other script files

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [May 24, 2022, 3:46am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/2 "2022-05-24T03:46:15Z")

</div>

As I see there is boolean parameter (false/true) in scene.whenReadyAsync() - [Scene | Babylon.js Documentation](https://doc.babylonjs.com/typedoc/classes/babylon.scene#whenreadyasync)  
Seems it works - [https://playground.babylonjs.com/#20OAV9#6276](https://playground.babylonjs.com/#20OAV9#6276)

 ![Screen Shot 2022-05-24 at 06.53.59](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/3/33243083c9ce94b20dab7c1dd2de9b67febb236e.jpeg)

Probably you didn’t put `await` before function call?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 24, 2022, 10:20am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/3 "2022-05-24T10:20:13Z")

</div>

would you be able to reproduce that? playground or project would be wonderful, this way we can see what the issue might be or how we can help and make it work.

---

<div class="post-metadata">

**Author:** ![waverider404](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/waverider404/32/17464_2.png) [@waverider404](https://forum.babylonjs.com/u/waverider404)\
**Post date:** [May 24, 2022, 4:08pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/4 "2022-05-24T16:08:23Z")

</div>

unfortunately still the same issue  
I will try making a repro

---

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [May 25, 2022, 5:37am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/5 "2022-05-25T05:37:16Z")

</div>

This is definitely a bit of a strange one that we are still looking at @RaananW , but since our update from around 5.0 to the latest, none of our scene.whenReadyAsync() are firing throughout our code base where they used to, so we are having to do some refactoring in the meantime to try to work around this until we understand it better.

I see one possible change in here is this but I’m not sure yet why that would be affecting its behavior so dramatically: [better isReadyCheck (#12474) · BabylonJS/Babylon.js@d5e107d (github.com)](https://github.com/BabylonJS/Babylon.js/commit/d5e107d48d57a0b228479473aaa4f09230d7713d)

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 25, 2022, 9:56am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/6 "2022-05-25T09:56:12Z")

</div>

I’ll have to look into that. Seems to be related to the pending data not cleared for some reason.

If you have a way to reproduce this easily it would be great, if not I’ll try a few playgrounds hoping to find a way to get it (not) to work

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 25, 2022, 9:56am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/7 "2022-05-25T09:56:16Z")

</div>

Assigned @RaananW on May 25, 2022, 9:56am UTC



---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [May 25, 2022, 3:08pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/8 "2022-05-25T15:08:01Z")

</div>

@Deltakosh - can you think of a reason the pending data will not be cleared?  
I can’t seem to be able to reproduce this, but still trying 🙂

---

<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:** [May 25, 2022, 3:21pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/9 "2022-05-25T15:21:27Z")

</div>

Hum maybe a long timeout?

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [June 14, 2022, 3:21pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/10 "2022-06-14T15:21:27Z")

</div>

Bumping this again - Do we have a reproduction for this one? I still haven’t managed to reproduce this

---

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [June 15, 2022, 3:29pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/11 "2022-06-15T15:29:32Z")

</div>

Hi @RaananW , apologies for the silence. We haven’t managed to repro but I also know @jure managed to fix it. @jure i forget how you managed that but forum floor is yours if you want to weigh in!

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 15, 2022, 3:44pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/12 "2022-06-15T15:44:57Z")

</div>

would be awesome if we know so that we can push the fix in Babylon 🙂

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [June 27, 2022, 9:46am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/13 "2022-06-27T09:46:29Z")

</div>

Unassigned @RaananW on June 27, 2022, 9:46am UTC



---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [June 27, 2022, 9:46am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/14 "2022-06-27T09:46:50Z")

</div>

Please assign me again if there is a reproduction. We really want to be sure we solved the issue

---

<div class="post-metadata">

**Author:** ![Impurity](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/impurity/32/10512_2.png) [@Impurity](https://forum.babylonjs.com/u/Impurity)\
**Post date:** [July 29, 2024, 10:08am UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/15 "2024-07-29T10:08:43Z")

</div>

I have a potential repro, but its in my own public github project. Does the repro have to be in playground?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [July 29, 2024, 4:08pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/16 "2024-07-29T16:08:11Z")

</div>

I would be highly preferable in the playground for efficiency 🙂 but more than anything it has to be small with only the impactful piece as much as possible.

---

<div class="post-metadata">

**Author:** ![Impurity](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/impurity/32/10512_2.png) [@Impurity](https://forum.babylonjs.com/u/Impurity)\
**Post date:** [July 29, 2024, 6:15pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/17 "2024-07-29T18:15:28Z")

</div>

Unfortunately I’d be unable to reproduce it. But perhaps the snippet code helps. I have a work around so just leaving it here incase it helps yall.

```auto
export const purpleSpace = (props: { scene: BABYLON.Scene }) => {
    const { scene } = props;
    return skybox({ scene, file: 'skyboxes/purple', id: 'purple-skybox' });
};

export const yellowSpace = (props: { scene: BABYLON.Scene }) => {
    const { scene } = props;
    return skybox({ scene, file: 'skyboxes/yellow', id: 'yellow-skybox' });
};

const skybox = (props: { file: string; scene: BABYLON.Scene; id: string }) => {
    const { scene, file, id } = props;
    const skyboxMaterial = new BABYLON.StandardMaterial(`${id}-material`, scene);
    skyboxMaterial.backFaceCulling = false;
    skyboxMaterial.disableLighting = true;
    skyboxMaterial.reflectionTexture = new BABYLON.CubeTexture(file, scene);
    skyboxMaterial.reflectionTexture.coordinatesMode = BABYLON.Texture.SKYBOX_MODE;
    skyboxMaterial.diffuseColor = new BABYLON.Color3(0, 0, 0);
    skyboxMaterial.specularColor = new BABYLON.Color3(0, 0, 0);
    const skybox = BABYLON.MeshBuilder.CreateBox(`${id}-mesh`, { size: 10000 }, scene);
    skybox.infiniteDistance = true;
    skybox.material = skyboxMaterial;
    skybox.metadata = 'skybox';
    return skybox;
};

```

But if I have purpleSpace in 1 scene, and transition to another that also uses purpleSpace, it wont load. I was forced to use a different skybox like yellowSpace in order to bypass the issue.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 29, 2024, 6:23pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/18 "2024-07-29T18:23:42Z")

</div>

I am willing to check your repo. Gimme the URL 😉

---

<div class="post-metadata">

**Author:** ![Impurity](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/impurity/32/10512_2.png) [@Impurity](https://forum.babylonjs.com/u/Impurity)\
**Post date:** [July 29, 2024, 6:41pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/19 "2024-07-29T18:41:55Z")

</div>

**REDACTED**  
Added a `BUG-INSTRUCTIONS.MD` for extra help. Branch is called babylon-bug.

---

<div class="post-metadata">

**Author:** ![roland](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/roland/32/38940_2.png) [@roland](https://forum.babylonjs.com/u/roland)\
**Post date:** [July 29, 2024, 7:30pm UTC](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667/20 "2024-07-29T19:30:39Z")

</div>

Actually it’s the  
`await load` which rejects and you don’t handle the error so the execution stops. The `load` function can’t load some of the models.

If you `try-catch` it it will go on:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/c/acda4e30b328d09c54adcde615b644dc270c6cab.jpeg)

Very very nice stuff buddy!! 💪

[Next page](https://forum.babylonjs.com/t/scene-whenreadyasync-not-firing/30667.md?page=2)
