The Ultimate Config/Build files -Simulators iPhone plus sizes differ.

I think I used an example file to set up my minimal Config and Build files,  some many moons ago, and now can’t locate the documentation on line. Is there an update anywhere or can anyone advise on the following. 

My app has been working ok on many different device sizes and is updated to suit new devices ok. But now I am getting differences only on iPhone  Plus  devices during testing on Xcode versus CoronaLabs simulators.

In Corona simulator it works as expected and see [close] dimensions 1920 x 1080,

yet in Xcode simulator I get dimensions 2208x1242 .

I am suspecting a missing default file such as Default-640h@3x.png. But why is 2208x1242 being set?

When I look at the config file in use on this app[see below] , I am now sightly confused as  I have lost documentation.

The naming convention is different to standards , so can anyone advise me in the two subject questions.

  1. The config file description. [or do I rewrite using standard conventions?]

  2. What is the problem for Xcode [real life?] simulation versus Corona Simulator?

 Non plus type iPhones are  all ok from  4 thro’ X on both simulators

  Also  iPads are ok on both

So only  it is the Plus type iPhones that are not correct.

I have a LaunchScreen and all ok there also.

-------Config -------------------------------------

local aspectRatio =display.pixelHeight/display.pixelWidth

application =

{

content =

{

width = aspectRatio > 1.5 and 320 or math.ceil(480 /aspectRatio),

height = aspectRatio<1.5 and 480 or math.ceil (320*aspectRatio),

scale = “letterbox”,

fps = 60,

imageSuffix = {

["@2x"] = 1.5,

["@3x"] = 2.5,

antialias = false

– xAlign = “center”,

–yAlign = “center”

}

}

}

-----------Build-------------------------------------

settings =

{

    orientation =

    {

       

         default = “landscapeLeft”,

       supported = { “portrait”,“landscapeLeft”, “landscapeRight”,“portraitUpsideDown”}

    },

     iphone =

    {

   

        plist =

        {

        NSAppTransportSecurity =

            {

                NSAllowsArbitraryLoads = true,

            },

            CFBundleIconFiles =

             {

                “Icon-40.png”,–

                “Icon-58.png”,–

                “Icon-76.png”,–

                “Icon-80.png”,–

                “Icon-87.png”,

                “Icon-120.png”,–

                “Icon-152.png”,–

                “Icon-167.png”,–

                “Icon-180.png”

                },–

            

            UILaunchStoryboardName = “LaunchScreen”,  – Required!

            UIStatusBarHidden = false,

            CFBundleDisplayName = “UKLoTis”,

            CFBundleName = “UKLoTis”,

        },

    },

          

}

My reference for devices is this table https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html

Apple did something really bizarre with the plus models.  The physical screens are 1080x1920, but they have a virtual size of 1242x2208 for native apps and the device scales it down to the physical 1080x1920 apps. However, for apps that use OpenGL or full-screen mode, you should be getting a 1080x1920 screen size for Corona apps. That’s what I would expect.  However, the Xcode simulator provides us native numbers instead of the right device numbers for some reason. On a real device, it should report 1080x1920.

This should be a non-issue because you’re virtual screen is going to be 320x320*aspectRatio which is the same regardless of the screen size reported.

Rob

Thanks Rob, Bizarre is quite a mild description.

I can overcome this by looking at a ‘parallel universe’ iPhone spec , i.e. one or the other pixels hxw. I assume this is the same for all Plus models as I have only tested 8 plus.

I think I understood all,  except your point 320x320*aspectratio. Is this ratio h/w or w/h or something else [will go away and search].

The no-issue  comment might be ok for image games etc but mine seems different. here is why…


I am probably not alone but my app is a spreadsheet style  app. e.g. lots of rows and columns view on screen via a TableView. Each row has to be readable, So as the device gets smaller the fewer rows are displayed, The larger the device more rows get displayed.

But it is not a simple row to deviceheight ratio, because, as the device gets smaller the rows get less readable. So to keep rows   readable, there  must be a  minimum ‘read’ height,

As the device gets larger and the numbers of rows increase, so as not to look like a  sillygraph paper the Row height increases slightly for aesthetic reasons as well or would be far too many rows e.g. if kept at say iPhone 5 row height on a 12.9 iPad it would be overloading information at once.

Also , considering upport for orientation, incorporated,  the rows seen per device obviously is different portrait vs landscape.

When you consider information available via  Corana on how to calculate row height, what we have  is in pixels  , e.g. realheight realwidth etc. But then as the devices increase the dpi increases. So need further compensation.  We don’t seem to have access to that in software, do we?

So calculating  row height in pixels alone cannot be used as a constant across devices, due to physical device size and DPI change.

If we do, the row lay out varies visually.

So initially I set up tables per device bounds as fixed rows per device, not elegant but did achieve with trial an error

{  am I seeing this too complex?]

I am trying to make a routine to do this ‘automatically’ so I dont have to create new tables for each device that comes along .

Is there any easy way to determine the actual physical device, i.e type name as user bought, dimensions in inch/mm ?  The answer I am sure is no.

I am not looking for solution code etc [would be nice though] but some of your thoughts,  guidance or pointers. Thanks again

Oh a PS Is there an approach via the config using the deafaultxxx@y style definition for devices.?

A further PS if I use the ‘parallel universe’ view of Plus models, what dimensions would I use for calculation eg height/row size? The corona simulator spec or xcode .  It would seem I cant verify layout on the xcode simulator , can I?

I feel like you might try adaptive scale mode in your config

https://docs.coronalabs.com/guide/system/adaptiveScale/index.html

Corona, when using “letterbox”, allows you to create a virtual screen that your app will use. Nothing pixel related really matters. If you decide your app works best if you set the width to 100, then Corona will figure out the device pixels for you and handle the math behind the scene to convert your desired 100 content units to device pixels. You, the developer only have to worry about your content units.

Now every mobile device screen (and computer screen for that part) has a height and width. Rarely will that device be the same physical pixels high as it is wide. The difference between a screen’s width and it’s height is known as “Aspect Ratio”. Because of old school devices like the original iPhone, developers got used to a screen that 1.5x pixels taller than it was wide (i.e. 320 x 480, the size of the original iPhone). Apple then came out with the iPhone 4 at 640x960,  This was still a 1.5x aspect ratio device (960/640) but it had twice the pixels in both direction. The Corona config.lua of a width of 320x480 still fit that device perfectly because Corona would manage scaling things up by 2X to fit.

But devices didn’t stay at 1.5x to 1 (height to width).  The iPad’s are 4:3 (aspect ratios are typically expressed as height:width or width:height – almost always a landscape representation). HDTV is 16:9 (which is common now for many phones).  It’s now impossible to make a config.lua that will let you define the width and height in a way that your virtual screen is a perfect fit to the shape of the screen.

Because of this, there are two schools of thought.  1. Just give up and use a 1.5:1 (3:2) aspect ratio for config.lua and use techniques to get the actual screen size and manage positioning that virtual screen on the physical screen or 2. Compute the actual height of the screen based on a desired width. This is what the Ultimate config.lua does for you. 

“So great, I’ll go #2, my virtual screen will fit the actual screen”.  Well not so fast. For some apps, this makes sense, for many others it’s a horrible idea.  For a game like Angry Birds, it’s critical that the distance from the sling shot to the pig’s tower be a fixed distance.  On the other hand a card game like solitaire you might be happier spreading your card stacks out to fill the screen. Business apps may not work as well with a centered content area. It might make more sense to anchor your content area to the top of the device. No one config.lua can fit everyone’s needs.

Many of the problems with this whole setup comes down to two things. 1. People want to use display.contentHeight/.contentWidth to figure out the screen size. They don’t understand, these two values are exactly the values you put in config.lua. So if you set width = 100 display.contentWidth will be 100, period.  If you use the Ultimate config.lua, those values get calculated a bit and will vary. However Corona already provides you with the numbers you really want with display.actualContentWidth, display.actualContentHeight. These values use your defined width, and return you the actual height.   2. People don’t understand that your defined content area is frequently smaller than the actual screen and there are areas outside the content area that you have to do extra work to fill.  

By default, Corona will center that virtual content area in the center of the screen. So on an iPhone 4 with a 320x480 content area, it’s a perfect fit. On an iPhone 5, which has a virtual screen size of 320x568 with the same config.lua has to place those extra 88 content units some where. With a centered content area, 44 points will be above the content area and 44 will be below it. That means that the top left corner on a portrait Corona app on an iPhone 5 will be 0, -44. You end up having to place edge based items like navigation bars using the constants display.screenOriginX and display.screenOriginY. Those will return where the screen starts.

As a business app, you don’t really want this. You want 0, 0 to be the top left. The Ultimate config.lua makes this happen. But you could also change the yAlign value in your config.lua “top” instead of “center” (and xAlign = “left”).  So if you did this and used display.actualContentHeight to reference the bottom of the screen, you would be golden. “Oh that’s perfect, lets do that”. Not so fast, it has it’s drawbacks too. If you want to center items, display.contentCenterX, display.contentCenterY may now longer be the actual center of the screen (you moved your virtual content area up the screen!) so you have to compute your own center (display.actualContentHeight / 2).

Now to add a lot of fun to this problem, the poster above talked about a scaling option called “adaptive”.  This is a pretty cool feature. You no longer have to figure out any of this. You don’t set a width or height at all.  Something really cool happens. 

If you take an iPhone app and run it on an iPad, you should get about the same number of rows out of a tableView with each row being visually larger. Text will be larger. A display.newSwitch() will be significantly larger. You are taking a phone screen and scaling it up to a tablet screen without giving the app any extra space.  With an adaptive config.lua, on a phone you pretty much get a 320 content unit width on an iPhone 4/5. For an iPhone 6 since it’s a larger screen, you will get a 375 point wide content area and on an iPad, you will get a 768 point wide screen.  The virtual area will adapt better to larger screen sizes. If you put a iPhone 4, 6, 8plus and iPad on the same table, that switch will be the exact same size on each of them. Your tableView rows will be the exact same height, the fonts will be the same size. You just get more real estate with bigger screens.  This is a great option for business apps.

The config.lua gets simplified to this:

application = { content = { scale = "adaptive", fps = 60, imageSuffix = { ["@2x"] = 2, ["@3x"] = 3, } } }

You might want to give this a try and look at different devices.

Rob

Wow, that is a fantastic detailed response  Rob.

I will need s few coffee s tomorrow to go through this [1:45 am here].  and think out the options. I like the adaptive so will try that first.

 Arteficio

Thanks for the pointer certainly a small consensus here on adaptive. 

I will try tomorrow …

Thanks again

A quick run with your example and no real thinking this end, all IPhone code runs, but crazy stuff and crashes with iPad.

Tomorrow?

My reference for devices is this table https://developer.apple.com/library/content/documentation/DeviceInformation/Reference/iOSDeviceCompatibility/Displays/Displays.html

Apple did something really bizarre with the plus models.  The physical screens are 1080x1920, but they have a virtual size of 1242x2208 for native apps and the device scales it down to the physical 1080x1920 apps. However, for apps that use OpenGL or full-screen mode, you should be getting a 1080x1920 screen size for Corona apps. That’s what I would expect.  However, the Xcode simulator provides us native numbers instead of the right device numbers for some reason. On a real device, it should report 1080x1920.

This should be a non-issue because you’re virtual screen is going to be 320x320*aspectRatio which is the same regardless of the screen size reported.

Rob

Thanks Rob, Bizarre is quite a mild description.

I can overcome this by looking at a ‘parallel universe’ iPhone spec , i.e. one or the other pixels hxw. I assume this is the same for all Plus models as I have only tested 8 plus.

I think I understood all,  except your point 320x320*aspectratio. Is this ratio h/w or w/h or something else [will go away and search].

The no-issue  comment might be ok for image games etc but mine seems different. here is why…


I am probably not alone but my app is a spreadsheet style  app. e.g. lots of rows and columns view on screen via a TableView. Each row has to be readable, So as the device gets smaller the fewer rows are displayed, The larger the device more rows get displayed.

But it is not a simple row to deviceheight ratio, because, as the device gets smaller the rows get less readable. So to keep rows   readable, there  must be a  minimum ‘read’ height,

As the device gets larger and the numbers of rows increase, so as not to look like a  sillygraph paper the Row height increases slightly for aesthetic reasons as well or would be far too many rows e.g. if kept at say iPhone 5 row height on a 12.9 iPad it would be overloading information at once.

Also , considering upport for orientation, incorporated,  the rows seen per device obviously is different portrait vs landscape.

When you consider information available via  Corana on how to calculate row height, what we have  is in pixels  , e.g. realheight realwidth etc. But then as the devices increase the dpi increases. So need further compensation.  We don’t seem to have access to that in software, do we?

So calculating  row height in pixels alone cannot be used as a constant across devices, due to physical device size and DPI change.

If we do, the row lay out varies visually.

So initially I set up tables per device bounds as fixed rows per device, not elegant but did achieve with trial an error

{  am I seeing this too complex?]

I am trying to make a routine to do this ‘automatically’ so I dont have to create new tables for each device that comes along .

Is there any easy way to determine the actual physical device, i.e type name as user bought, dimensions in inch/mm ?  The answer I am sure is no.

I am not looking for solution code etc [would be nice though] but some of your thoughts,  guidance or pointers. Thanks again

Oh a PS Is there an approach via the config using the deafaultxxx@y style definition for devices.?

A further PS if I use the ‘parallel universe’ view of Plus models, what dimensions would I use for calculation eg height/row size? The corona simulator spec or xcode .  It would seem I cant verify layout on the xcode simulator , can I?

I feel like you might try adaptive scale mode in your config

https://docs.coronalabs.com/guide/system/adaptiveScale/index.html

Corona, when using “letterbox”, allows you to create a virtual screen that your app will use. Nothing pixel related really matters. If you decide your app works best if you set the width to 100, then Corona will figure out the device pixels for you and handle the math behind the scene to convert your desired 100 content units to device pixels. You, the developer only have to worry about your content units.

Now every mobile device screen (and computer screen for that part) has a height and width. Rarely will that device be the same physical pixels high as it is wide. The difference between a screen’s width and it’s height is known as “Aspect Ratio”. Because of old school devices like the original iPhone, developers got used to a screen that 1.5x pixels taller than it was wide (i.e. 320 x 480, the size of the original iPhone). Apple then came out with the iPhone 4 at 640x960,  This was still a 1.5x aspect ratio device (960/640) but it had twice the pixels in both direction. The Corona config.lua of a width of 320x480 still fit that device perfectly because Corona would manage scaling things up by 2X to fit.

But devices didn’t stay at 1.5x to 1 (height to width).  The iPad’s are 4:3 (aspect ratios are typically expressed as height:width or width:height – almost always a landscape representation). HDTV is 16:9 (which is common now for many phones).  It’s now impossible to make a config.lua that will let you define the width and height in a way that your virtual screen is a perfect fit to the shape of the screen.

Because of this, there are two schools of thought.  1. Just give up and use a 1.5:1 (3:2) aspect ratio for config.lua and use techniques to get the actual screen size and manage positioning that virtual screen on the physical screen or 2. Compute the actual height of the screen based on a desired width. This is what the Ultimate config.lua does for you. 

“So great, I’ll go #2, my virtual screen will fit the actual screen”.  Well not so fast. For some apps, this makes sense, for many others it’s a horrible idea.  For a game like Angry Birds, it’s critical that the distance from the sling shot to the pig’s tower be a fixed distance.  On the other hand a card game like solitaire you might be happier spreading your card stacks out to fill the screen. Business apps may not work as well with a centered content area. It might make more sense to anchor your content area to the top of the device. No one config.lua can fit everyone’s needs.

Many of the problems with this whole setup comes down to two things. 1. People want to use display.contentHeight/.contentWidth to figure out the screen size. They don’t understand, these two values are exactly the values you put in config.lua. So if you set width = 100 display.contentWidth will be 100, period.  If you use the Ultimate config.lua, those values get calculated a bit and will vary. However Corona already provides you with the numbers you really want with display.actualContentWidth, display.actualContentHeight. These values use your defined width, and return you the actual height.   2. People don’t understand that your defined content area is frequently smaller than the actual screen and there are areas outside the content area that you have to do extra work to fill.  

By default, Corona will center that virtual content area in the center of the screen. So on an iPhone 4 with a 320x480 content area, it’s a perfect fit. On an iPhone 5, which has a virtual screen size of 320x568 with the same config.lua has to place those extra 88 content units some where. With a centered content area, 44 points will be above the content area and 44 will be below it. That means that the top left corner on a portrait Corona app on an iPhone 5 will be 0, -44. You end up having to place edge based items like navigation bars using the constants display.screenOriginX and display.screenOriginY. Those will return where the screen starts.

As a business app, you don’t really want this. You want 0, 0 to be the top left. The Ultimate config.lua makes this happen. But you could also change the yAlign value in your config.lua “top” instead of “center” (and xAlign = “left”).  So if you did this and used display.actualContentHeight to reference the bottom of the screen, you would be golden. “Oh that’s perfect, lets do that”. Not so fast, it has it’s drawbacks too. If you want to center items, display.contentCenterX, display.contentCenterY may now longer be the actual center of the screen (you moved your virtual content area up the screen!) so you have to compute your own center (display.actualContentHeight / 2).

Now to add a lot of fun to this problem, the poster above talked about a scaling option called “adaptive”.  This is a pretty cool feature. You no longer have to figure out any of this. You don’t set a width or height at all.  Something really cool happens. 

If you take an iPhone app and run it on an iPad, you should get about the same number of rows out of a tableView with each row being visually larger. Text will be larger. A display.newSwitch() will be significantly larger. You are taking a phone screen and scaling it up to a tablet screen without giving the app any extra space.  With an adaptive config.lua, on a phone you pretty much get a 320 content unit width on an iPhone 4/5. For an iPhone 6 since it’s a larger screen, you will get a 375 point wide content area and on an iPad, you will get a 768 point wide screen.  The virtual area will adapt better to larger screen sizes. If you put a iPhone 4, 6, 8plus and iPad on the same table, that switch will be the exact same size on each of them. Your tableView rows will be the exact same height, the fonts will be the same size. You just get more real estate with bigger screens.  This is a great option for business apps.

The config.lua gets simplified to this:

application = { content = { scale = "adaptive", fps = 60, imageSuffix = { ["@2x"] = 2, ["@3x"] = 3, } } }

You might want to give this a try and look at different devices.

Rob

Wow, that is a fantastic detailed response  Rob.

I will need s few coffee s tomorrow to go through this [1:45 am here].  and think out the options. I like the adaptive so will try that first.

 Arteficio

Thanks for the pointer certainly a small consensus here on adaptive. 

I will try tomorrow …

Thanks again

A quick run with your example and no real thinking this end, all IPhone code runs, but crazy stuff and crashes with iPad.

Tomorrow?