Immersive mode problems

Create issue
Issue #101 resolved
Juno Nguyen created an issue

The app is unable to guarantee the activation of immersive mode at all times upon startup, and there are more chances of failure than success.

Also, rendering is no longer correct once the app loses and regains focus (returning to home button, activating recent tasks) (refer to screenshot).

I have encountered similar problems before (when implementing this on my own fork), and was not able to rectify them correctly. I have not been able to perfectly replicate this bug as well on this build.

Will reply if any progress is achieved.

PS: This was encountered on Nexus 5 running on Android 5.0.2.

Comments (20)

  1. Juno Nguyen reporter

    It looks like due to some inner structure (probably on SDL2 layer), the rendering window size is calculated before navigation bar is hidden and view is visible to user, leading to rendering area not fully covering the entire screen.

    I managed to achieve a workaround by moving the function to onResume() which is called just before onWindowFocusChanged(boolean hasFocus). Immersive mode is now far more stable, even upon switching among apps.

        protected void onResume() {
                | View.SYSTEM_UI_FLAG_FULLSCREEN
                | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

    Would be great if this can be verified.

  2. Juno Nguyen reporter

    @MartinFelis, I have realized that one of your recent commits renamed a setBorderless to setImmersive. How exactly is this called? Is this a mean to optionally disable Immersive Mode? If it does, please do let me know, as I would like to note this among the documentation.

  3. Martin Felis repo owner

    In the internal android related code I added the love::android::setImmersive (bool immersive_active) enables or disables immersive mode. It gets called from within LÖVE when enabling or disabling fullscreen either via conf.luaor using love.window.setMode(width, height, mode). If you request fullscreen you get immersive mode otherwise you get the default mode with navigation and top bar.

    It's a bit slow and causes a small pause, so you do not want to call it frequently.

  4. Juno Nguyen reporter

    @MartinFelis Are you able to confirm that this works? As of the latest commit, I have not been able to achieve immersive mode in anyway. What I did includes all of these methods individually and together at the same times:

    function love.load()
        love.window.setMode(0,0, {fullscreen=true})
    function love.conf(t)
        t.window.borderless = true
        t.window.fullscreen = true
        t.window.immersive = true

    Is there anything I'm missing?

  5. Juno Nguyen reporter

    The *.love file works on the provided nightly, however, I am not able to re-produce similar result on my own project.

    Neither of,0,{fullscreen=true}), and t.window.fullscreen = true produce consistent or reliable outcome, and so even more is any combination of them.

    What exactly am I supposed to do to reliably enable this?

  6. Juno Nguyen reporter

    love.window.setFullscreen(true) now works upon startup, but does not seems to working properly nevertheless.

    Despite correctly returning 1920 and navigation bar being hidden, the app does not correctly calculate the screen's width, leading to some very apparent misalignment. Specifically, in my project, objects being restrained to visible screen are not able to reach the area where navigation used to be.

    On the other hand, upon app switching, the navigation bar area is no longer rendered (navigation bar still being hidden), leaving only the background color.

  7. Martin Felis repo owner

    What do you mean with love.window.setFullscreen(true) works on startup? If you run it in love.load() or where is this function supposed to work?

    Also reaching the navbar area does not seem to be a problem for me (see the two images for reference). Does it also fail for you using

  8. Juno Nguyen reporter

    Yes, on startup as in in love.load()

    I have no problem with or other simple testing projects, but I my currently active project still encounters this loss of rendering area upon switching app. It's probably something specific to this project.

    This project is a little too big at this point (with lots of classes and libraries) to pinpoint what might have caused that. I'm also taking a break from it.

    But as far as the goes, it works. It's probably more or less safe to consider this resolved.

  9. Log in to comment