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

Enabling fullscreen on Android causes the app to toggle fullscreen mode continuously in a loop #2838

Closed
SDLBugzilla opened this issue Feb 11, 2021 · 1 comment
Labels
waiting Waiting on user response

Comments

@SDLBugzilla
Copy link
Collaborator

This bug report was migrated from our old Bugzilla tracker.

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

Comments on the original bug report:

On 2018-02-25 16:57:24 +0000, Olli Kallioinen wrote:

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.

On 2018-02-25 17:44:10 +0000, Sam Lantinga wrote:

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"

On 2018-02-25 19:37:04 +0000, Olli Kallioinen wrote:

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

On 2018-02-25 20:13:10 +0000, Olli Kallioinen wrote:

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.

On 2018-02-26 10:51:20 +0000, Olli Kallioinen wrote:

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)

On 2018-02-27 11:48:31 +0000, Olli Kallioinen wrote:

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 ***

@SDLBugzilla SDLBugzilla added bug waiting Waiting on user response labels Feb 11, 2021
@slouken slouken removed the bug label May 11, 2022
@slouken
Copy link
Collaborator

slouken commented Nov 5, 2023

I believe this is fixed in the latest SDL release. Please feel free to reopen this if that's not the case.

@slouken slouken closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting Waiting on user response
Projects
None yet
Development

No branches or pull requests

2 participants