Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Issues when toggling fullscreen #87

Open
Beuc opened this issue Jul 25, 2019 · 8 comments
Open

Issues when toggling fullscreen #87

Beuc opened this issue Jul 25, 2019 · 8 comments

Comments

@Beuc
Copy link
Contributor

Beuc commented Jul 25, 2019

Hi,

I'm trying to fix long-standing issues with fullscreen in my RenPyWeb port.

(Btw, I'm not doing anything with the "Fullscreen" button from the default shell.html, which seems not to play well with SDL2.)

I'm doing tests with a simple app (https://gist.github.com/Beuc/0ab96af2fde381dd40d818f6b13450c0) where 'F' toggles fullscreen at the SDL2 level (SDL_SetWindowFullscreen). Initial size is 800x600, my resolution is 1920x1080.

Results:

  • F, Esc: restores canvas to 800x600; RESIZED(800x600) + SIZE_CHANGED(800x600) events on exit
  • F, F: keeps canvas at 1920x1080 when back in windowed mode; SIZE_CHANGED(1920x1080, wrong size) event on exit, missing resized event
  • F, Esc, F, F: sometimes sets canvas to 1920x1080 but with updated screen portion still 800x600 (black area at the right)
  • [maintain F pressed]: buggy result (windowed mode, black background as-if-fullscreen, 1920x1080 canvas)
  • Note: without SDL_WINDOW_RESIZABLE, canvas is properly reset to 800x600 in the HTML page, but same bugs otherwise

I need to investigate further (possibly with a GL app) but I wanted to share my initial results (wrong callback parameters, wrong size reset, concurrency issue(s?)).

@Daft-Freak
Copy link
Member

Daft-Freak commented Jul 26, 2019

Hmm, the resizing should be handled by emscripten_request_fullscreen_strategy(called in here). Possibly that doesn't handle pressing esc correctly?

@Beuc
Copy link
Contributor Author

Beuc commented Jul 26, 2019

On that particular point, it seems Esc. is directly handled by the browser in a basic way, while SDL_SetWindowFullscreen calls emscripten_exit_fullscren() which is responsible for calling the strategy exit callback explicitely.
(not sure how that translates to a missing event and incorrect arguments, though - the basic Esc. handle appears to behave more correctly)

@Daft-Freak
Copy link
Member

Daft-Freak commented Jul 26, 2019

OK, misread that and assumed that it was the other way around. I put some logging in the JS parts and it looks something like this:

F, F:

INFO: toggling fullscreen (cur_state: NO)
INFO: toggled fullscreen (cur_state: YES)
JSEvents_requestFullscreen
_registerRestoreOldStyle
INFO: Window 1 size changed to 1920x1080
INFO: fullscreen: YES
INFO: Window 1 resized to 1920x1080
INFO: fullscreen: YES
INFO: toggling fullscreen (cur_state: YES)
emscripten_exit_fullscreen
call canvasResizedCallback
INFO: toggled fullscreen (cur_state: NO)
INFO: Window 1 size changed to 1920x1080
INFO: fullscreen: NO
restoreOldStyle undefined

F, Esc:

INFO: toggling fullscreen (cur_state: NO)
INFO: toggled fullscreen (cur_state: YES)
INFO: Window 1 size changed to 1920x1080
INFO: fullscreen: YES
INFO: Window 1 resized to 1920x1080
INFO: fullscreen: YES
JSEvents_requestFullscreen
_registerRestoreOldStyle
restoreOldStyle undefined
call canvasResizedCallback
INFO: Window 1 size changed to 800x600
INFO: fullscreen: NO
INFO: Window 1 resized to 800x600
INFO: fullscreen: NO

So, restoreOldStyle gets called after calling the callback if you use exit_fullscreen and after if you don't...

Edit: Commenting out the if here makes both behave the same. (The callback gets called later in restoreOldStyle).

@Beuc
Copy link
Contributor Author

Beuc commented Jul 26, 2019

(I wish I'd seen you edit earlier, sadly it wasn't there in my mailbox OTL
Good catch!)

This fixes the canvas size, the "size changed" event size (and consequently the missing "resized" event) - though maintaining F pressed still produces a buggy result.

Do you want to file a bug against Emscripten, as restoreOldStyle looks like the proper place to call the callback?

@Beuc
Copy link
Contributor Author

Beuc commented Jun 27, 2020

Hi,

It seems fullscreen support broke, somewhere since 1.39.13, probably with version_21 and the 2.0.10 merge (I don't see fullscreen-related commits on the Emscripten side).

Now the browser doesn't go fullscreen at all, this can be checked quickly with the simple app in original post: the application believes it is fullscreen but the browser doesn't do anything.

@Daft-Freak
Copy link
Member

Daft-Freak commented Jun 27, 2020

I just checked with latest SDL2 and it's still working here (Firefox/Linux), my Emscripten may be a little outdated though...

Edit: Yeah, 1.39.12 (82e8463b8ac0d17d0b640ce834cb938b7609d14c) (had forced port to latest commit for testing something else)

@Beuc
Copy link
Contributor Author

Beuc commented Jun 27, 2020

Hi, how do you recommend testing with the latest SDL2?

@Beuc
Copy link
Contributor Author

Beuc commented Jun 28, 2020

bisect says Emscripten broke it in emscripten-core/emscripten@852ca4e

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants