Accessing `presentationController` inside `viewDidLoad` creates a retain cycle

Originator:m.quinones.garcia
Number:rdar://40092137 Date Originated:09/05/2018
Status:Open Resolved:
Product:UIKit Product Version:Xcode 9.3, iOS 11.3
Classification:Other bug Reproducible:Always
 
Area:
UIKit

Summary:
Presenting a view controller through `present` API creates a system `UIPresentationController` subclass by default. A retain cycle will be created between presented controller and _UIFullscreenPresentationController if the property `presentationController` is accessed inside `viewDidLoad` method.

Steps to Reproduce:
1. Create a view controller that reads `presentationController` property during `viewDidLoad`
2. Instantiate that view controller through `present` API in the presenting controller
3. Dismiss controller through `dismiss` API

Expected Results:
Presented view controller is deallocated after dismissal

Actual Results:
Presented view controller stays in memory, never deallocated

Version/Build:
Xcode 9.3 iOS 11.3

Configuration:
See attached project reproducing issue

Comments

I am encountering this issue in iOS 11.4 and iOS 12.2/12.4 as well. I have no way to mitigate this.

No issues with iOS 13.1 so I guess this has been fixed moving forward.


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!