SafeAreaInsets not updating correctly on childViewControllers

Originator:emilio.pavia
Number:rdar://36070764 Date Originated:December 15 2017
Status:Open Resolved:
Product:iOS + SDK Product Version:iOS 11.2 (15C107)
Classification:UI/Usability Reproducible:Always
 
Area:
UIKit

Summary:
In my app I have a view controller with a vertical stackView inside a scrollView. Every row is a child view controller with a collectionView (that scrolls horizontally). I noticed that safeAreaInsets is correctly set from parent to child view controller only if its view is inside the bounds of the parent's scrollView.

Here is a video that shows the issue: https://youtu.be/1jFE0gTlp64

Steps to Reproduce:
1. Open SafeAreaInsetsBug.xcodeproj
2. Run on an iPhone X simulator
3. Rotate to landscape
4. Scroll to the third row
5. Scroll the collectionView to the rightmost cell

Expected Results:
The collection view should respect its superview safeAreaInsets.

Actual Results:
The left safe area inset for the collection view is correct, but the right one is not. Moreover if you scroll down to the 5th row (and more) you'll find out that neither the left inset is set correctly.

Version/Build:
iOS 11.2 (15C107)
Xcode 9.2 (9C40b)

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!