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

Android status/system bars randomly won't hide when resuming the app #8995

Open
leonstyhre opened this issue Feb 4, 2024 · 3 comments
Open
Assignees
Milestone

Comments

@leonstyhre
Copy link

Hi!

There is an issue on Android where the system bars sometimes won't get hidden when focusing/resuming the app window. It happens randomly although much more frequently when the screen has to be rotated.

For example my application always runs in landscape mode, so if I have the home screen set to portrait mode and then switch between this and my application then the system bars won't get hidden around every third or fourth time. They will stay indefinitely and the only way to get rid of them is to go back to the home screen and then back to the app again.

Adding the following to SDLActivity::onSystemUiVisibilityChange() seems to completely resolve the issue but I'm pretty sure this is not a proper fix (and I think it only works on Android 11 and later):

getWindow().getDecorView().getWindowInsetsController().hide(
    android.view.WindowInsets.Type.systemBars());

Based on the behavior I observe when the screen rotation takes place I suspect that this could be some kind of race condition where you are hiding the system bars before the screen rotation has been completed. However the issue can also occur when rotation does not take place, i.e. when the home screen is also set to landscape mode. But that is much less frequent and may happen only once every 10 or 15 tries.

@slouken slouken added this to the 3.2.0 milestone Mar 3, 2024
@1bsyl
Copy link
Contributor

1bsyl commented Mar 4, 2024

@leonstyhre
I have disable the navigation bar feature in my side so I really don´t know what we should expect.
because it shows and then disappears and was more a source of trouble.
also my android setup is really out of date.

public void onSystemUiVisibilityChange(int visibility) seems to be user to hide the system bar..
can you check that "rehideSystemUi()" is called ?

( or maybe we should add a call:
mSingleton.sendCommand(COMMAND_CHANGE_WINDOW_STYLE, fullscreen ? 1 : 0);
in the onResume function )

@leonstyhre
Copy link
Author

Thanks for taking a look at this! I tried adding the following to SDLActivity::onResume() while also commenting out my overloaded onSystemUiVisibilityChange() method:

mSingleton.sendCommand(COMMAND_CHANGE_WINDOW_STYLE, mFullscreenModeActive ? 1 : 0);

While this improves things it's not perfect. The result is a bit glitchy as the system bars will be displayed when resuming the app, then disappear, then appear immediately again and disappear once more. So it happens twice for some reason. With the code mention in my first post it's much more seamless, the system bars are just faded out when resuming the app, which is the behavior you would expect.

@slouken slouken modified the milestones: 3.2.0, 2.32.0 Mar 10, 2024
@Robyt3
Copy link

Robyt3 commented May 15, 2024

I have also encountered this issue. It happens very consistently in portait mode for an app that uses landscape mode per default. When holding the phone in landscape mode the entire time, the bug does not seem to happen on my phone.

Not directly related to this bug, but I noticed that a wrong constant seems to be used as a system UI visibility flag:

int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
window.getDecorView().setSystemUiVisibility(flags);

int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN |
View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.INVISIBLE;
SDLActivity.this.getWindow().getDecorView().setSystemUiVisibility(flags);

The flag View.INVISIBLE is not supposed to be used with setSystemUiVisibility, though because its actual value is 4 it has no effect, as this is identical to value of the flag View.SYSTEM_UI_FLAG_FULLSCREEN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants