safeAreaInsets on UIWindow behavior silently changed between iOS 11 and iOS 12

Originator:steipete
Number:rdar://42372793 Date Originated:19-Jul-2018 10:41 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 12b4
Classification:Serious Bug Reproducible:Always
 
Summary:
safeAreaInsets on UIWindow behavior silently changed between iOS 11 and iOS 12:

iPad 10.5’:
iOS 11.4: safe area insets for window: UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0)
iOS 12b4: safe area insets for window: UIEdgeInsets(top: 20.0, left: 0.0, bottom: 0.0, right: 0.0)

iPhone X:
iOS 11.4: safe area insets for window: UIEdgeInsets(top: 44.0, left: 0.0, bottom: 34.0, right: 0.0)
iOS 12b4: safe area insets for window: UIEdgeInsets(top: 44.0, left: 0.0, bottom: 34.0, right: 0.0)

Is this expected? Is this documented anywhere? 

The documentation does not mention what is expected for the main window.
If we can use the rootViewController’s view as documentation base, then it seems the new behavior is correct.

Steps to Reproduce:
Run attached sample project to see output.

Expected Results:
No change, or a documented change. I can’t find release notes mentioning this anywhere?

Actual Results:
This caused regressions in our code which were tricky to find.

Version:
iOS 12b4

Notes:
This change is problematic because people used that to detect iPhone X: https://twitter.com/LeoNatan/status/1019863191155769344

(That’s not what caused issues for us, we used it to detect hardware insets, rounded corners and sensor housing on iPhone X or future devices, that cannot be hidden via software.)

Attaching our full detection code inclusive hack here: https://gist.github.com/steipete/6bf2f916699eeec176c7a51e79238290 (1000 character limit, so needed to use a Gist)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!