[SOLVED] OpenFL's stage.stageWidth/stage.stageHeight incorrect value when using Android 4.4 Immersive Mode

I’m pretty sure I’ve saw this issue posted somewhere before but can’t find it anymore. The problem is when using <android android-target-sdk="19" /> with <window ... fullscreen="true" /> the application will use Android’s Immersive Mode (which is great) but the stage.stageWidth and/or stage.stageHeight will have value as if the navigation bar is still there (I guess this only happen in devices with software navbar like on Nexus devices).

For example on my 2012 Nexus 7 with 4.4.2 using the above configuration will make the Application use Immersive Mode and use the whole screen, but the stage.stageHeight (or portrait) will show value of 1225 instead of the correct 1280.

So my question is

  • Is this a known issue already
  • If it is, is there a fix incoming
  • Or is there any workaround

This problem pretty much defeat the whole purpose of having an immersive mode fullscreen if we can’t really tell the real screen size.

OpenFL 2.2.7 & Lime 2.1.2

I believe this is where Java tells the C++ process that it’s resized:


It sounds like entering immersive mode is triggering a resize in the Java level, but it is not actually triggering a “surface changed” event, so perhaps there is somewhere else in Java that the size could be listened to, and pushed back into the C++ process?

FWIW I found this http://stackoverflow.com/questions/20555083/android-gl-screen-size-in-immersive-mode thread. Idk maybe I’ll investigate further.

Are you listening for RESIZE events? OpenFL sometimes gives incorrect values on the first frame, but generally it corrects itself by frame 2.

I didn’t listen to resize, but I doubt listening to it will change anything. Even when listening to it I still have to use stage.stageWidth/stage.stageHeight to know the new size.

Well, yes. What I’m really asking is whether you waited a few frames before checking stageWidth and stageHeight. (I assume you did, but I just want to be sure.)

I put the trace on enter frame, it doesn’t change, still show 800x1225 instead of 800x1280.

I would like to see a fix for this issue too.

So far, onSurfaceChanged is called with the correct widthxheight. But somehow the change is not propagated to Lime/OpenFL. Here is the relevant logcat.

$ adb logcat | grep V/VIEW V/VIEW (22543): onSurfaceCreated V/VIEW (22543): Thread = 726 V/VIEW (22543): onSurfaceChanged 800,1225 V/VIEW (22543): Thread = 726 V/VIEW (22543): onSurfaceChanged 800,1280 V/VIEW (22543): Thread = 726

Hmm okay it seems that there is something wrong with my code. Just tried it with clean project and wait for onResize and it shows the size properly.

I’m sorry for wasting everyone (especially Joshua) time for this.

Hey, no, this is the best type of solution – it works, and no extra work is needed, a win for everyone! :wink: