debugLayer.hide doesn't seem to work

Hello,
I am trying this little piece of code in playground and I was expecting the debugger to hide after showing it:

scene.debugLayer.show({embedMode: true});
scene.debugLayer.hide();

What do I miss?

Is it not working here: Babylon.js Playground ???

Maybe a problem with a browser. Which browser do you use?

Works at home with Google chome, Opera and Firefox

I am on Chrome Version 81.0.4044.113.

Sample: https://www.babylonjs-playground.com/#20OAV9#1604

Actually, also in your example, if you comment hide -> run, then comment show and uncomment hide -> run. it doesn’t hide

Add a setTimeout (). He works

https://www.babylonjs-playground.com/#20OAV9#1605

This is interesting, hide only works with setTimeout. Even when I comment show, hide doesn’t work without setTimeout.

I don’t explain it either. But it works.

This is because we could face a race condition issue. The show is async and is not instantaneous. So if it takes longer than expected then hide will be executed BEFORE the layer is actually displayed

3 Likes

debugLayer.show returns a promise. So if you wanted to do something to the inspector after showing it, you can add a continuation.

https://www.babylonjs-playground.com/#20OAV9#1614