We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1895 - Malformed window resize is sometimes reported on activity resume
Summary: Malformed window resize is sometimes reported on activity resume
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: ARM Android (All)
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-06 04:09 UTC by ny00
Modified: 2017-08-15 22:59 UTC (History)
0 users

See Also:


Attachments
Fix for display mode updates (2.69 KB, patch)
2013-06-06 04:09 UTC, ny00
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ny00 2013-06-06 04:09:19 UTC
Created attachment 1176 [details]
Fix for display mode updates

*** BEGIN WARNING ***

Before reading this, it worths to warn that the attached patch *may* break compatibility with a few Android apps. To be more specific I am talking about any app which, for any arbitrary reason, queries the display mode of the desktop/display/window *after* a resize or restore event arrives.

The reason is that with the given patch, the display mode actually gets updated.

*** END OF WARNING ***

Alright, on to the report itself. At the moment, when a screen rotation occurs, the display mode is not updated anywhere; Not for the window (if there is any), nor for the display.
One side effect of this occurs when the activity resumes. Basically, a SDL_WINDOWEVENT_RESTORED event is added to the queue. The addition of such an event results in an indirect check for any update to the window's dimensions, sending a resize event if necessary.

Problem is it queries a display mode at some point.

The given patch modifies the code so whenever a surface resize is detected (in the Java code), the screen's display mode as updated, along with the window's if there's any. I'm not sure it's the best way to handle that, but at least it seems to fix the issue for me.
Comment 1 ny00 2013-07-14 04:11:34 UTC
I wonder why I didn't think of this or at least comment about that earlier...

Anyway, there is one big problem with the current patch: A case of not being thread safe when updating the display mode (desktop, current and window if there's any).

Maybe the function SDL_SendWindowEvent from SDL_windowevents.c (called by the secondary SDL C thread) should update the window's display mode after a window resize event is sent, although it may seem a bit dangerous at the moment.

Furthermore, maybe the current display mode should be changed here, but not the desktop's.
Comment 2 ny00 2013-07-14 08:19:46 UTC
Of course there are chances that there is no window at all, yet an update to the display mode is still desired.

Due to the thread safety issues I am going to mark the current patch "obsolete", although it should still be available for reference.
Comment 3 ny00 2017-08-15 18:53:10 UTC
Just updating that I think this was resolved, at least after these commits were applied (see also bug 2808):

https://hg.libsdl.org/SDL/rev/f7d8e9d871c5
https://hg.libsdl.org/SDL/rev/82f21f6121db

I believe this bug can be marked as resolved. It can be re-opened if it is reproduced in any later revision of SDL2.
Comment 4 Sam Lantinga 2017-08-15 22:59:47 UTC
Glad to hear it, thanks!