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 4096 - Enabling fullscreen on Android causes the app to toggle fullscreen mode continuously in a loop
Summary: Enabling fullscreen on Android causes the app to toggle fullscreen mode conti...
Status: WAITING
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: Other Android (All)
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-25 16:57 UTC by Olli Kallioinen
Modified: 2018-02-27 11:48 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Olli Kallioinen 2018-02-25 16:57:24 UTC
I've gathered that nowadays hiding the Android navigation is done by providing the SDL_WINDOW_FULLSCREEN flag when creating the window.

This works OK on my actual Android device, but when I try the same app on the emulator, It keeps hiding and showing the navigation/title bars again and again in a loop.

The Android version I have on the emulator is showing a hint screen to the user about fullscreen mode (how to disable it) and I believe that might be causing the problem. I don't get this hint popup on my actual device.

The emulator I was using was Android 7.1.1 (API level 25).

I can investigate more a bit later if you are not able to reproduce this easily.
Comment 1 Sam Lantinga 2018-02-25 17:44:10 UTC
It sounds like Android doesn't know your application can handle screen size changes.

Can you check to make sure your app has these set for your activity in AndroidManifest.xml?
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
Comment 2 Olli Kallioinen 2018-02-25 19:37:04 UTC
Yep, I have those set. I'll try to investigate a bit too.

Here's the project I'm testing with: https://github.com/suikki/simpleSDL
Comment 3 Olli Kallioinen 2018-02-25 20:13:10 UTC
After a quick debug run here's what's going on:

02-25 21:41:35.010 19153-19170/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9d605480: ver 2 0 (tinfo 0x9d603370)
02-25 21:41:35.078 19153-19169/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9be3c640: ver 2 0 (tinfo 0xa47ed7a0)
02-25 21:41:35.095 19153-19153/com.my.exampleapp V/SDL: surfaceChanged()
02-25 21:41:35.095 19153-19153/com.my.exampleapp V/SDL: pixel format RGB_565
02-25 21:41:35.096 19153-19153/com.my.exampleapp V/SDL: Window size: 768x1280
02-25 21:41:35.099 19153-19169/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9be3c640: ver 2 0 (tinfo 0xa47ed7a0)
02-25 21:41:35.968 19153-19153/com.my.exampleapp V/SDL: onWindowFocusChanged(): false
02-25 21:41:35.968 19153-19153/com.my.exampleapp V/SDL: nativePause()
02-25 21:41:35.995 19153-19169/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9be3c640: ver 2 0 (tinfo 0xa47ed7a0)
02-25 21:41:36.010 19153-19153/com.my.exampleapp V/SDL: surfaceChanged()
02-25 21:41:36.010 19153-19153/com.my.exampleapp V/SDL: pixel format RGB_565
02-25 21:41:36.010 19153-19153/com.my.exampleapp V/SDL: Window size: 768x1136
02-25 21:41:36.017 19153-19169/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9be3c640: ver 2 0 (tinfo 0xa47ed7a0)
02-25 21:41:36.109 19153-19153/com.my.exampleapp V/SDL: onWindowFocusChanged(): true
02-25 21:41:36.109 19153-19153/com.my.exampleapp V/SDL: nativeResume()
02-25 21:41:36.110 19153-19170/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9d605480: ver 2 0 (tinfo 0x9d603370)
02-25 21:41:36.177 19153-19169/com.my.exampleapp D/EGL_emulation: eglMakeCurrent: 0x9be3c640: ver 2 0 (tinfo 0xa47ed7a0)

Seems that the hint popup gives an onWindowFocusChanged() event that causes a call to handleNativeState() that calls nativePause().

Then pause is calling: SDL_OnWindowMinimized() that again calls: SDL_UpdateFullscreenMode() maybe that causes the loop.



I'm relatively sure that if you have an Android version that shows this fullscreen hint popup (I don't remember seeing it on older versions). You could reproduce the problem. Although I'm not sure what the logic is for showing the popup, maybe it is only shown on the first run of the program.
Comment 4 Olli Kallioinen 2018-02-26 10:51:20 UTC
Probably a related issue on an Android device that has a software navigation bar (not hardware buttons):

1) start app so that it's fullscreen
2) swipe (twice) from the top to bring up the notifications
3) press back

Expected behavior:
The app return to focus in fullscreen mode

Actual behavior:
sometimes the navigation buttons are not hidden automatically, and even when they are, the navigation bar does not animate away smoothly but jerks a bit. Probably there are again some extra window state events that restart the animation or sometimes prevent it depending on the event timing.

(I was using the same project that I linked above on a nexus 4)
Comment 5 Olli Kallioinen 2018-02-27 11:48:31 UTC
I did a bit more testing with a few different versions of Android. Mostly with the emulator as I only have one device here (actually the device is a nexus 5 with android 6.0.1 and not nexus 4 like I said before).


emulator with API 19 [4.4.2]: working ok
 nexus 5 with API 23 [6.0.1]: hiding notifications bugged (see earlier comment)
emulator with API 24 [7.0.0]: infinitely looping fullscreen mode (the original issue)
emulator with API 25 [7.1.1]: working ok


I also tried my test app with an emulator with API level 16. While I didn't see the earlier problems, my test app started with the navigation bar visible, but after switching to another program and back the bar was hidden until touching anywhere on the screen when the bar becomes visible again.

This API level does not support the newer immersive mode and it seems that SDL is using the older mode where, if the navigation bar is hidden, the bar will pop back if the screen is touched anywhere.

*** I don't think that behavior is useful for games, so I think it would be better to not hide the navigation bar at all for API < 19 ***