p2 / OAuth2

OAuth2 framework for macOS and iOS, written in Swift.
Other
1.14k stars 275 forks source link

Memory issue on iOS after dismissing SFSafariViewController #378

Closed ZhanatM closed 5 months ago

ZhanatM commented 2 years ago

What did you do?

We observe a retain cycle between OAuth2Authorizer and OAuth2SFViewControllerDelegate. This happens because the safari view controller delegate method is not called when the view controller is dismissed programmatically so that safariViewDelegate is not set to nil. Apple's documentation states that safariViewControllerDidFinish() is only called when the Done button is tapped.

We called open func authorizeEmbedded(from context: AnyObject, params: OAuth2StringDict? = nil, callback: @escaping ((_ authParameters: OAuth2JSON?, _ error: OAuth2Error?) -> Void)) on OAuth2.

We've checked both cases of authorizeEmbeddedAutoDismiss: true and false.

What did you expect to happen?

safariViewDelegate is set to nil when the safari view controller is dismissed programmatically to resolve the retain cycle.

What happened instead?

Safari View Controller is dismissed, but safariViewControllerDidFinish() is not called.

Environment

Xcode Version: 12.5.1 (12E507) OAuth2: 5.2.0 Deployment Target: iOS 11.4 Base SDK: 14.5 Method of Integration: Swift Package Manager

ossus-lib commented 5 months ago

This should be fixed with #380 , which is in 5.3.3