scene.whenReadyAsync not firing

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

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

Probably you didn’t put await before function call?

2 Likes

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.

1 Like

unfortunately still the same issue
I will try making a repro

1 Like

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)

2 Likes

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

1 Like

@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 :slight_smile:

Hum maybe a long timeout?

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

1 Like

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!

1 Like

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

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

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

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

1 Like

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.

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.

I am willing to check your repo. Gimme the URL :wink:

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

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:

Very very nice stuff buddy!! :muscle:

2 Likes