Commit 7d9b28d5 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] Fixing FirstRunChromeSigninViewController leak

FirstRunChromeSigninViewController is being leaked when of all those
conditions are true:
 + it is the delegate of its own presentation controller.
 + it is shown inside a navigation view controller in second and last
position.
 + the navigation view controller is dismissed with the view controller
displayed.

Then a retain cycle is created with FirstRunChromeSigninViewController
and UIFormSheetPresentationController.
This is a bug in iOS, and should not happen.
Since FirstRunChromeSigninViewController cannot be swiped to be
dismissed, it doesn't need to be the delegate of its presentation
controller.

The fix is to not set the presentation controller delegate if the view
controller is not part of a navigation controller.
The fix is done in ChromeSigninViewController since
FirstRunChromeSigninViewController is a subclass of if.

Apple Feedback: https://feedbackassistant.apple.com/form-response/15480140

Bug: 1004695
Change-Id: I85f7721c4bef1c95d6d30abfd06e4ce83954209f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1823198Reviewed-by: default avatarStepan Khapugin <stkhapugin@chromium.org>
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699786}
parent bbdeabcf
......@@ -200,7 +200,6 @@ enum AuthenticationState {
_currentState = NULL_STATE;
self.modalPresentationStyle = UIModalPresentationFormSheet;
self.presentationController.delegate = self;
}
return self;
}
......@@ -857,6 +856,18 @@ enum AuthenticationState {
[self updateGradientColors];
[[_gradientView layer] insertSublayer:_gradientLayer atIndex:0];
[self.view addSubview:_gradientView];
if (!self.navigationController) {
// If the view controller is part of a navigation controller, there is no
// need to be the presentation delegate. The point to be the delegate is to
// receive notification when the view is swiped to be dismissed.
// The view cannot be swiped away if it is inside a navigation controller.
// In that case, the ChromeSigninViewController is leaked because of some
// iOS bug. See crbug.com/1004695.
// This view controller is presented by itself for signin-in, and it is
// presented inside a navigation view controller when being part of the
// first run.
self.presentationController.delegate = self;
}
}
- (void)viewWillAppear:(BOOL)animated {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment