| Summary: | Malformed window resize is sometimes reported on activity resume | ||
|---|---|---|---|
| Product: | SDL | Reporter: | ny00 |
| Component: | video | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | ARM | ||
| OS: | Android (All) | ||
| Attachments: | Fix for display mode updates | ||
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. 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. 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. Glad to hear it, thanks! |
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.