Multi canvas, multi scene and requestFullscreen

I have a page with several 3D models on different canvases. I was originally creating multiple engine/scenes, but this blows up on mobile, so I found the multiple canvas feature. I want to have buttons on each canvas to turn them into fullscreen (so obviously one canvas/scene at a time). But when I try to call engine.enterFullscreen(); I get an error. Bad stack trace:

babylon.js:16 Uncaught (in promise) TypeError: fullscreen error
    at Function.t._RequestFullscreen (babylon.js:16)
    at t.enterFullscreen (babylon.js:16)

I’m not sure if calling it even makes sense, since the engine’s _renderingCanvas isn’t the actual rendering canvas and there’s no meaningful way to make it be.

I can work around by calling requestFullscreen on the canvas directly, but here’s the bug report anyway.

But calling this.engine.resize() works. Will it behave correctly if called on fullscreen enter/leave?

From information you provided I would check if you have "this" in both cases

or

Sorry, I copy/pasted without this, but that’s not the bug. The code is properly using this.

Another bug with multi canvas: if scene.clearColor is transparent, the canvas isn’t transparent, and it accumulates from the previous frame.

1 Like

Could you check if it happens also after scene.autoClear = true and scene.autoClearDepthAndStencil = true

1 Like

Yes, even with these two lines the same behavior happens.

    this.scene.clearColor = new BABYLON.Color4(0, 0.0, 0, 0.1);
    this.scene.autoClear = true;
    this.scene.autoClearDepthAndStencil = true;

It also seems that the initial frame is transparent as expected, and then the background turns into black over the next few frames, not at once.

https://playground.babylonjs.com/#L1TX4W#28 PG that reproduces the issue.

2 Likes

Try to pass true as the third parameter of engine.registerView and see if that helps.

2 Likes

It is definitely better - https://playground.babylonjs.com/#L1TX4W#29

2 Likes