Only half of the screen is present after changing mobile's orientation



I’ve built “DysplayingABitmap” sample for Android and have a problem with device orientation:
after I change orientation – only half of the screen is present.

after I change orientation back – the screen content is shifted (OpenFL logo should be in the center of the screen).

The problem is reproduced on two different devices (Android 5.0, Android 6.0). Does it normal behavior for just built sample applications? How can I manage orientation to make it “normal”? :slight_smile:

I would be grateful for any advices.

P.S. sorry for bad english :slight_smile:


Hmm, this might be a regression, what version of OpenFL are you using?

Did you make any changes to the sample? How does the PiratePig sample behave?

Thank you for your help! :slight_smile:


OpenFL Command-Line Tools (7.1.0-LUnrhU)

No, I built the sample just in time after created it

The same:

P.S. I’m not sure that it helps, but when I hide application (not close) then open it from recent applications (android’s navigation square button) the problem disappeared.


OpenFL 7.1.0 is a bit outdated by now. Does the problem still reproduce with latest versions? (OpenFL 8.1.1 and Lime 6.3.1)


I’ve removed OpenFL and install new OpenFL 8.1.1 and Lime 6.3.1, also I’ve deleted project’s export folder, reexported project to Android by “openfl build android”, uninstalled the application from the device, cleared Android Studio caches, but the problem is still reproduced :frowning:


Has anyone else seen a similar issue?


I remember it happened one time to me, but I don’t remember how I fix it (maybe it was an issue on old openfl…).


Hello, just in case here is my configuration for today:

macOS Sierra

OpenFL Command-Line Tools (8.1.1-LVPK6O)

MacBook-Pro-Kleon:PiratePig valera$ lime
Lime Command-Line Tools (6.3.1)

MacBook-Pro-Kleon:PiratePig valera$ openfl setup
lime is up to date
hxcpp is up to date
lime-samples is up to date
openfl-samples is up to date
actuate is up to date
box2d is up to date
layout is up to date

I’ve found that SDLActivity.setOrientation method doesn’t run after I change device’s orientation. Should it be called every time when screen orientation changed?

Also I’ve noticed that SDLActivity.setRequestedOrientation always is -1 and it called only one time when application is running

Here is SDLActivity log:

05-29 13:02:47.526 24687-24704/org.openfl.samples.piratepig V/SDL: Running main function hxcpp_main from library
05-29 13:02:47.571 24687-24687/org.openfl.samples.piratepig V/SDL: onWindowFocusChanged(): true
05-29 13:02:47.601 24687-24704/org.openfl.samples.piratepig V/SDL: setOrientation() orientation=-1 width=1080 height=1920 resizable=true hint=

at this point I changed device’s orientation

05-29 13:02:53.952 24687-24687/org.openfl.samples.piratepig V/SDL: surfaceChanged()
pixel format RGB_565
05-29 13:02:53.954 24687-24687/org.openfl.samples.piratepig V/SDL: Window size: 1920x1080


Okay! Reproduced the regression, and it is fixed. We needed to mark the rendering as dirty when the screen was resized – that was the cause of the objects being rendered in the wrong place. The second is that we stop rendering when the screen is not dirty, but this was causing an issue during the rotation. For now, I’ve added code to force rendering for a time after rotating, which is fixing the issue, but hopefully in the future we’ll have something a little cleaner.

This will go out in the next release, sorry for the regression, and thank you for your help! This wasn’t showing up for most content which A.) renders every frame and/or B.) has a locked orientation to portrait or landscape.

Thanks :grinning:


Okey, I get it, Thank you :grinning:


Yes bug seen on android-phones, ios works good. When rotate phone - half screen and bad position.
HTML5 target, Chrome browser. (latest openfl and lime)


The latest changes in the repo should help, the key is the __setTransformDirty() call when the window is resized. You can also call stage.invalidate () yourself every frame, or when a resize occurs, and it might do it, too :slight_smile:


stage.invalidate () - does not help

Browser.window.addEventListener("orientationchange", onChangeOrient);

function onChangeOrient(e:Event):Void 
		if (Browser.window.orientation == -90 || Browser.window.orientation == 90)
			haxe.Timer.delay(function () { addChild(this._hider); }, 100);
			if (this._hider.parent != null) removeChild(this._hider);

stage.addEventListener(Event.RESIZE, onResize);

private function onResize(e:Event):Void 

All two uses - bag also appeared


Fixed in the latest release