iPhone X top inset values

local statusBarH = display.topStatusBarContentHeight local topInset, leftInset, bottomInset, rightInset = display.getSafeAreaInsets() Results in xCode simulator iphone 6 statusBarH=42, topInset=42 iPhone X statusBarH=94, topInset=94 while in corona simulator iphone 6 statusBarH=42, topInset=0 iPhone X. statusBarH=82, topInset=44

This is strange, isn’t it ?

I expected top inset to be zero in all devices except iPhone x. I wanted to use this assumption to modify layout for the X

What version of Corona are you using?

Rob

2017.3155

Hi MartingK, Did you find a solution to this issue?

I’m checking with Engineering. Our skins are approximations in particular with things like status bars. But I would think the numbers should be the same or closer.

Rob

Something is fishy, maybe ambiguous documentation or a misunderstanding from me or an xCode simulator bug, or a Corona bug.

topInset in Corona simulator understandably returns ZERO on iPhone 6

while on xCode simulator iPhone 6 it returns a 42

Safe area insets are not 0s for everything except iPhone X. Safe insets would include such features as:

  • curved screen like on iPhone X

  • software buttons

  • status bars

  • Android TV/tvOS - overscan area

  • navigation bar on Android

Corona Simulator safeInsets are  inconsistent with what would be reported on real devices. We’re working on fixing those issues.

Thanks for the info.

And just to clarify why I expect TopInset to be zero, it is because I have UIStatusBarHidden=true, and all other conditions you mentioned don’t hold.

Solving the inconsistency will make us understand better

Hi Vlad and Everyone;

I’m going to throw in a side question here related to the iPhone X because you contributors/readers are those presently dealing with the changes demanded by this phone. It seems better than starting a new forum thread. My question is:

If you were going to write a small block of code as a test for “Am I running on an iPhone X?”, what would that block be composed of?  Primarily dimensional checks? Additional system.getInfo checks? Any thoughts?

Thanks;

Steve

On real device it would be something like

system.getInfo("architectureInfo") == "iPhone10,6"

Also, I would recommend just using safe insets for layout.

Thanks Vlad.

That was a part of what I was thinking of using as a check. Of course I won’t trust it until someone has a device in-hand and confirms this return string. :slight_smile:

As a secondary check, I was thinking of testing whether

(display.actualContentHeight ~= display.safeActualContentHeight) or (display.actualContentWidth ~= display.safeActualContentWidth)

as one or the other of these will always be true on an iPhone X depending on orientation.

Steve

This won’t work since in portrait mode left and right offsets are 0. You can just check for specific pixelWidth

Hmmm. I am not testing offsets. Though I understand the relationship of offsets with safeActualContentHeight and safeActualContentWidth.

This is what I get in the simulator with the iPhone X skin. The app the is Portrait (only). Note the safeActualContentHeight IS different than the actualContentHeight (946 versus 1024).

                    ==================================================================

                    SCREEN DIMENSIONS - Model: iPhone    Architecture: x86_64

                    display.actualContentHeight = 1024

                    display.viewableContentHeight = 1024

                    display.contentHeight = 1024

                    iP X display.safeActualContentHeight = 946

                    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                    display.actualContentWidth = 472

                    display.viewableContentWidth = 472

                    display.contentWidth = 768

                    iP X display.safeActualContentWidth = 472

                    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                    iP X display.safeScreenOriginX = 0

                    iP X display.safeScreenOriginY = 44

                    iP X display.getSafeAreaInsets top,left,bottom,right = 44, 0, 34, 0

                    ==================================================================

Steve

local t, l, b, r = display.getSafeAreaInsets()
l+r+display.safeActualContentWidth == display.actualContentWidth

Same goes for top, bottom and heights

Of course. But that is NOT what I suggested as a test (see above).

I’m just talking about an easy test. That being:

if (display.actualContentHeight ~= display.safeActualContentHeight)

OR (display.actualContentWidth ~= display.safeActualContentWidth)

If either is true (the “either” eliminates the orientation question you raised), then it can be no other device that I know of yet (i.e. must be an iPhone X).

Steve

Steve, I think I need to add a very important to this discussion.

display.contentWidth = the value YOU put in config.lua for width.

display.contentHeight = the value YOU put in config.lua for height. Nothing more, nothing less.

display.actualContentWidth and display.actualContentHeight are going to be scaled to your content area.  Let’s say you define width, height to 320 and 480.  On an iPhone 5, the pixel width is 640 and the pixel height is 1136. Since this is exactly 2X scale, then your display.actualContentWidth = 320 and display.actualContentHeight = 568.  

You cannot use .actualContent* to determine the device you’re on because the numbers are scaled to your content area and you would spend a lot of time hand calculating those values.

We offer display.actualPixelWidth and display.actualPixelHeight which will return you the device’s pixel count which would be a better choice. However, Vlad’s suggestion to use the iPhone10,6 string is a published value by Apple and it alone should be safe to use. But if you insist on using a pixel measurement, you should use the pixel measures. 

Rob

Thanks Steve, Vlad, and Rob for some very useful comments. I’d been wondering about this issue as well. 

Can  this currently be tested inside the simulator on iPhoneX?

Insets - yes. system.getInfo(“architectureInfo”) would return simulator or x86 on simulator or xcode simulator.