From 1eb1e20a427ffb6b6fce7cbb14c645a365431994 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 29 Oct 2018 14:38:23 -0700 Subject: [PATCH 1/2] Fix popSystemNavigator --- .../ios/framework/Source/FlutterPlatformPlugin.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index fb52763303e08..28493c9373d9d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -200,15 +200,23 @@ - (void)popSystemNavigator { // in the navigation hierarchy. // It's also possible in an Add2App scenario that the FlutterViewController was presented // outside the context of a UINavigationController, and still wants to be popped. + // + // We should avoid nilling out the FlutterEngine's view controller here (e.g. `[_engine.get() + // setViewcontroller:nil]`). Doing so could potentially get a caller into a bad state where the + // view controller has been nilled out and they aren't explicity bringing it back because they + // didn't realize they would have to, or they only ever called this from Dart code without any + // corresponding native code to re-attach the FlutterViewController, e.g. + // https://github.com/flutter/flutter/tree/master/dev/integration_tests/platform_interaction + // Unfortunately, this means that a simple call to `SystemNavigator.pop()` from Dart will not be + // enough to release some resources that could be released by nilling out the FlutterEngine's + // ViewController. UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController; if ([viewController isKindOfClass:[UINavigationController class]]) { [((UINavigationController*)viewController) popViewControllerAnimated:NO]; - [_engine.get() setViewController:nil]; } else { auto engineViewController = static_cast([_engine.get() viewController]); if (engineViewController != viewController) { [engineViewController dismissViewControllerAnimated:NO completion:nil]; - [_engine.get() setViewController:nil]; } } } From 16b5b5a554f94bc792115500510072c4f3381a07 Mon Sep 17 00:00:00 2001 From: Dan Field Date: Mon, 29 Oct 2018 16:18:42 -0700 Subject: [PATCH 2/2] remove unnecessary comment --- .../ios/framework/Source/FlutterPlatformPlugin.mm | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm index 28493c9373d9d..71940926f4a3d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm @@ -200,16 +200,6 @@ - (void)popSystemNavigator { // in the navigation hierarchy. // It's also possible in an Add2App scenario that the FlutterViewController was presented // outside the context of a UINavigationController, and still wants to be popped. - // - // We should avoid nilling out the FlutterEngine's view controller here (e.g. `[_engine.get() - // setViewcontroller:nil]`). Doing so could potentially get a caller into a bad state where the - // view controller has been nilled out and they aren't explicity bringing it back because they - // didn't realize they would have to, or they only ever called this from Dart code without any - // corresponding native code to re-attach the FlutterViewController, e.g. - // https://github.com/flutter/flutter/tree/master/dev/integration_tests/platform_interaction - // Unfortunately, this means that a simple call to `SystemNavigator.pop()` from Dart will not be - // enough to release some resources that could be released by nilling out the FlutterEngine's - // ViewController. UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController; if ([viewController isKindOfClass:[UINavigationController class]]) { [((UINavigationController*)viewController) popViewControllerAnimated:NO];