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

[patch proposal] Fix SDL reporting wrong window size on resume #1711

Closed
SDLBugzilla opened this issue Feb 10, 2021 · 0 comments
Closed

[patch proposal] Fix SDL reporting wrong window size on resume #1711

SDLBugzilla opened this issue Feb 10, 2021 · 0 comments

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

These attachments are available in the static archive:

Reported in version: HG 2.1
Reported for operating system, platform: Android (All), All

Comments on the original bug report:

On 2014-12-07 01:47:26 +0000, Jonas Kulla wrote:

Created attachment 1960
proposed patch

At startup time, the single android window is assigned a "windowed" (window->windowed.{w,h}) size based on the current orientation of the mobile device; this size is never updated throughout the lifetime of the app.

This becomes problematic when the app is paused and then resumed in an orientation that it did not start up in. Eventually, 'SDL_OnWindowRestored()' is called, which calls 'SDL_UpdateFullscreenMode()'. This function is very problematic because it is written with a desktop monitor in mind: it tries to find a matching display mode for the windowed size, doesn't find any, and finally applies the windowed size as the fullscreen one. In the end, the windowed size is reported in a RESIZED event, which doesn't correspond to the actual surface size.

To see this in action: Start an orientation aware SDL app in eg. portrait mode, suspend the app, put the device into landscape orientation and resume the app. It will erroneously render in portrait mode (until the device is rotated again).

My first attempt at fixing this involved updating Android_Window->windowed inside 'Android_SetScreenResolution()', but that would mean writing fields from the Java thread that could potentially be read from by the native thread at the same time. A very low chance, but nevertheless.

Instead, I just completely disabled 'SDL_UpdateFullscreenMode()' for Android as tbh. this function makes absolutely no sense in the context of mobile screens. An even cleaner solution would be to introduce a third FULLSCREEN_* flag that indicates "don't mess with the current size in any way".

On 2015-02-19 04:21:27 +0000, Ryan C. Gordon wrote:

Tossing this bug to Gabriel for review.

--ryan.

On 2015-02-19 05:22:21 +0000, Ryan C. Gordon wrote:

Marking a large number of bugs with the "triage-2.0.4" keyword at once. Sorry if you got a lot of email from this. This is to help me sort through some bugs in regards to a 2.0.4 release. We may or may not fix this bug for 2.0.4, though!

On 2015-09-13 15:49:09 +0000, matt wrote:

Created attachment 2264
alternative workaround

I ran into this recently, worked around it by always forcing the current mode to match the resized screen resolution (patch attached).

On 2015-09-14 03:30:16 +0000, Alex Szpakowski wrote:

SDL's iOS backend code does something similar to that patch: https://hg.libsdl.org/SDL/file/c3c3cdaf37f9/src/video/uikit/SDL_uikitappdelegate.m#l385

On 2016-10-07 22:21:39 +0000, Sam Lantinga wrote:

Fixed, thanks!
https://hg.libsdl.org/SDL/rev/82f21f6121db

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

No branches or pull requests

1 participant