godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.45k stars 21.27k forks source link

Full screen start-up not working on HTML5 with slow network connection #43138

Open ConteZero opened 4 years ago

ConteZero commented 4 years ago

Godot version: Godot 3.2.3

OS/device including version: HTML5 (Chrome/Firefox on Linux)

Issue description: The exported HTML5 project with setting

window/size/fullscreen=true

starts in full screen if you test it with a fast connection (as example in a local development server), but if you test it with a relatively slow connection (I've tried with a 10 Mbit ADSL) you get this error on browser console

Uncaught (in promise) TypeError: Fullscreen request denied

Steps to reproduce: 1) Create a new godot project 2) Enable full screen start-up in project settings 3) Export HTML5 project 4) change default html code adding a button to manually start the engine 5) limit network speed form browser dev tools (set DSL or slower)

Minimal reproduction project: godot-test.zip

Calinou commented 4 years ago

In HTML5, enabling fullscreen requires user input to be performed at the same time it's requested. This is a security limitation applied by all web browsers.

ConteZero commented 4 years ago

Yes, but the way it is handled by godot make the full screen startup option useless for HTML5 export.

In my project as a workaround I directly request full screen mode from javascript before starting the engine, it works but then I cannot use OS.window_fullscreen (it does not detect the correct fullsceen status) so I'm forced enable/disable fullscreen with direct js calling JavaScript.eval(...)

Calinou commented 4 years ago

I think the only thing we can do here is to print a warning message if fullscreen is enabled in the Project Settings while running on HTML5.

Maybe we can point users towards implementing "click to enter fullscreen" functionality as well.