Go to file
Sam Lantinga 33ed20fafa Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground
Sylvain

With a Landscape application.
Going to background with Home Key, then foreground.
The screen is distorted.

This has been reported by Samsung. It happens on S5 and Samsung Alpha, see the video attached.

I have captured the following logcat:

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
I/SDL     (20549): SDL_Android_Init()
I/SDL     (20549): SDL_Android_Init() finished!
V/SDL     (20549): SDL audio: opening device
V/SDL     (20549): SDL audio: wanted stereo 16-bit 22.05kHz, 256 frames buffer
V/SDL     (20549): SDL audio: got stereo 16-bit 22.05kHz, 1764 frames buffer
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): onWindowFocusChanged(): false
V/SDL     (20549): onPause()
V/SDL     (20549): nativePause()
V/SDL     (20549): surfaceDestroyed()

Background / Foreground

V/SDL     (20549): onResume()
V/SDL     (20549): surfaceCreated()
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1080x1920
V/SDL     (20549): surfaceChanged()
V/SDL     (20549): pixel format RGB_565
V/SDL     (20549): Window size:1920x1080
V/SDL     (20549): onWindowFocusChanged(): true
V/SDL     (20549): nativeResume()



This seems to be related to the fact that I have in "AndroidManifest.xml":
android:configChanges="..."
Because of the fields: "orientation" and also "screenSize".


I have looked for another way to solve the issue. Discarding the "surfaceChanged" call, based on the "requestedOrientation" and the new Orientation. It seems to be better.


On my failing test case, the first "surfaceChanged()" is discarded. Sometimes the "focusChanged()" might appear between the two "surfaceChanged()", while the surface is not yet ready. Thus, discarding also the "nativeResume()".

So, for robustness, a call to "nativeResume()" is added at the end of "surfaceChanged()".

Some update:

1/ First I tried, to discard the surface using the current orientation (rather than width / heigh). -> that solve the issue sometimes, but not always.

2/ Samsung Certification now accepts my application that were previously failing.

3/ I personally now owns a Samsung S5, and was able to solve the issue on my side.

4/ I now use the patch and get no complaints from my users. (but I admit, nobody seemed to be complaining before neither...).

5/ I have added a v2 because of a new smart-phone called "Black Berry Passport" that has a square screen of 1440x1440. This screen has a "status bar" so the resolution is in fact : 1440x1308. (as reported by "surfaceChanged").

Problem is: the portrait resolution is in fact a Landscape!

So the "v1" patch is always discarding the "surface" of BlackBerry Passport. Which is terribly bad.


Hence, I added the "v2" patch not to discard the surface when aspect ratio is < 1.20. (BB 1440/1308 is : 1.1009). Which seems fair.
2015-06-16 22:16:35 -07:00
VisualC Only use explicit inlining - otherwise Visual Studio 2010 will inline SDL_zero(info) in SDL_vsnprintf() into a memset() call when compiling the Release x64 configuration. 2015-06-14 18:57:05 -07:00
VisualC-WinRT Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Xcode Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
Xcode-iOS Fixed building test programs on the iOS simulator 2015-05-28 18:57:57 -07:00
acinclude Fix a libtool issue with some mingw-w64 cross compilers (thanks, Ozkan!). 2015-05-26 19:54:06 -04:00
android-project Fixed bug 2774 - Android: screen distorted in Landscape after background/foreground 2015-06-16 22:16:35 -07:00
build-scripts WinRT: made sure build script generates Release-built binaries, by default 2015-06-14 20:15:36 -04:00
cmake configure/cmake/x11: Removed SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 test. 2015-06-08 01:13:51 -04:00
debian Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
docs Excluded SDL_egl.h from doxygen input. 2015-06-16 20:25:53 +02:00
include Fixed bug 3009 - Cannot compile SDL2 on Windows 2015-06-13 10:47:55 -07:00
premake X11: Add Xdbe support to message boxes (thanks, Melker!). 2015-05-28 00:30:21 -04:00
src Fixed bug 3015 - grab mouse inconsistent state 2015-06-15 23:44:08 -07:00
test Fixed comment in test program. 2015-06-16 20:27:01 +02:00
visualtest Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
.hgignore Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Android.mk Android: Replaced spaces with tab in Android.mk file. 2015-05-06 21:11:06 +02:00
BUGS.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
CMakeLists.txt Fixed bug 3009 - Cannot compile SDL2 on Windows 2015-06-13 10:47:55 -07:00
COPYING.txt Updated the copyright year to 2015 2015-05-26 06:27:46 -07:00
CREDITS.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
INSTALL.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Makefile.in Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Makefile.minimal Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Makefile.pandora Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Makefile.psp Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
Makefile.wiz Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
README-SDL.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
README.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
SDL2.spec.in Fixed docs path in RPM .spec file. 2015-06-04 19:05:01 -04:00
TODO.txt Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
VisualC.html Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
WhatsNew.txt Moved entry in WhatsNew.txt because it was already in 2.0.0 for Android and iOS. 2015-06-16 20:28:21 +02:00
autogen.sh Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
cmake_uninstall.cmake.in Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
configure Updated configure script. 2015-06-08 01:17:58 -04:00
configure.in configure/cmake/x11: Removed SDL_VIDEO_DRIVER_X11_CONST_PARAM_XDATA32 test. 2015-06-08 01:13:51 -04:00
sdl2-config.in Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
sdl2.m4 Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00
sdl2.pc.in Windows: Always set the system timer resolution to 1ms by default. 2015-04-20 12:22:44 -04:00

README.txt

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.


                         Simple DirectMedia Layer

                                  (SDL)

                                Version 2.0

---
http://www.libsdl.org/

Simple DirectMedia Layer is a cross-platform development library designed
to provide low level access to audio, keyboard, mouse, joystick, and graphics
hardware via OpenGL and Direct3D. It is used by video playback software,
emulators, and popular games including Valve's award winning catalog
and many Humble Bundle games.

More extensive documentation is available in the docs directory, starting
with README.md

Enjoy!
	Sam Lantinga				(slouken@libsdl.org)