Stage reports non-retina resolution on retina iOS devices


I’m making a game for mobiles. I listen to Event.RESIZE from the stage and resize my content to fit it into the screen. Everything works fine on Android, but not on iOS. On iOS stage.stageWidth and stage.stageHeight have “non-retina” values, e.g. 1024 and 768 on my iPad3 instead of 2048 and 1536. The content fills the whole screen and it’s visibly pixelated (it’s not that bad on ipad, but on iphone it looks ugly).

There is a number of topics about retina on the forums, but I couldn’t find a solution for my issue. It was mentioned somewhere that an app can start with wrong resolution values and later after Event.RESIZE they get updated with the right ones. As I said I do listen to this event. For me it gets fired 2 times in the beginning, both times stageWidth has the same wrong value.

Any ideas? Maybe I’m doing something wrong?


Which version of OpenFL and Lime are you using?

lime 2.9.1
openfl 3.6.1

I’m using old flashdevelop’s openfl template and I don’t have this problem. Here’s how my Main.hx looks like

 public function new()
        addEventListener(Event.ADDED_TO_STAGE, added);
function added(e)
        #if ios
        haxe.Timer.delay(init, 100); // iOS 6
private function init():Void
     trace(stage.stageWidth, stage.stageHeight);

I have tried to create an empty project very similar to your code:


import openfl.display.Sprite;

class Main extends Sprite {
    public function new () {	
        super ();
        stage.scaleMode = openfl.display.StageScaleMode.NO_SCALE;
        trace( "start", stage.stageHeight );
        haxe.Timer.delay( postponed, 5000 );

    private function postponed():Void {
        trace( "5 seconds passed", stage.stageHeight );

Same result :anguished:

I also tried to upgrade to the latest version of OpenFL and Lime, it didn’t help…

Can it be an Xcode thing? Some setting or a line in the plist?

Make sure you handle stage Event.RESIZE

watabou already addressed that.

watabou: does this happen with SimpleSWFLayout?

How about other people’s OpenFL apps? (Like mine.)

You aren’t setting the window width and height in project.xml, are you?

Yes. I just tried to run it on my iPhone4 and trace(stage.stageWidth, stage.stageHeight) in stage_onResize produces 320,480 (not 640,960 as it should).

Yours works fine :slight_smile:. If it didn’t work (correctly) it would mean that all my devices themselves are screwed and that’s unlikely.

This is what I have in my project.xml about the window:

<!-- General -->
<window background="0x000000" fps="60" hardware="true" allow-shaders="true" require-shaders="false" depth-buffer="false" stencil-buffer="false"/>
<!-- Desktop -->
<window width="960" height="540" fullscreen="false" resizable="true" borderless="false" if="desktop"/>
<!-- Mobile -->
<window width="0" height="0" fullscreen="true" if="mobile" />

I tried to remove some parts of it or the whole section with no effect.

Setting them to 0 is fine too. I’m not familiar with the fullscreen attribute, but it sounds like that isn’t the problem.

What version of Xcode are you using? And, for that matter, what version of OSX?

Xcode: 7.3.1
OSX: 10.11.6

Might be worth testing with the latest versions?

The latest versions are completely broken for me, but as I said

We have a <window allow-high-dpi="true" /> flag in the current Lime, but I believe it is true by default. This should change whether or not a retina surface is allowed or not

It seems it isn’t set true by default. I have problem with very poor graphics quality on mobile browsers. After changing this flag to true, graphics looks really great on mobile browsers.

Try this

import openfl.system.Capabilities;
trace("width " + Capabilities.screenResolutionX + " height " + Capabilities.screenResolutionY);