Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues when toggling fullscreen #87

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

Comments

@Beuc
Copy link
Contributor

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link
Member

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

This comment has been minimized.

Copy link
Contributor Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.