-
Notifications
You must be signed in to change notification settings - Fork 6k
SystemNavigator.pop can pop w/o UINavigationController #6341
Conversation
Also would be happy if there's a more idiomatic Objective C++ way to pass a weak reference to another object |
@interface FlutterPlatformPlugin : NSObject | ||
|
||
- (instancetype)initWithViewController:(fml::WeakPtr<UIViewController>)vc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a designated initializer? If so, please decorated this with NS_DESIGNATED_INITIALIZER
.
@@ -31,7 +32,20 @@ | |||
|
|||
using namespace shell; | |||
|
|||
@implementation FlutterPlatformPlugin | |||
@implementation FlutterPlatformPlugin { | |||
fml::WeakPtr<UIViewController> _vc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: We prefer not to abbreviate instance variable names in code. _viewController
works better IMO.
UIViewController* viewController = [UIApplication sharedApplication].keyWindow.rootViewController; | ||
if ([viewController isKindOfClass:[UINavigationController class]]) { | ||
[((UINavigationController*)viewController) popViewControllerAnimated:NO]; | ||
} else if (_vc && viewController != _vc.get()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The second check is redundant.
@@ -34,6 +35,7 @@ @implementation FlutterViewController { | |||
fml::scoped_nsobject<FlutterDartProject> _dartProject; | |||
shell::ThreadHost _threadHost; | |||
std::unique_ptr<shell::Shell> _shell; | |||
fml::WeakPtrFactory<FlutterViewController>* _weakFactory; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really try to avoid raw pointers. Please consider using a unique pointer. I realize the ObjC++ interop makes this a bit awkward.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit but looks good otherwise. Thanks!
@@ -65,6 +67,8 @@ - (instancetype)initWithProject:(FlutterDartProject*)projectOrNil | |||
bundle:(NSBundle*)nibBundleOrNil { | |||
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |||
if (self) { | |||
_weakFactory = std::unique_ptr<fml::WeakPtrFactory<FlutterViewController>>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: std::make_unique<fml::WeakPtrFactory<FlutterViewController>>(self)
is used in the engine for construction of unique pointer.
The CI bot failure is because of |
I was having issues with depot_tools clang-format not working, and I thought I fixed it but now it doesn't seem to get the right clang format rules... I'll fix that though. Thanks! |
flutter/engine@38a646e...3052dbd git log 38a646e..3052dbd --no-merges --oneline 3052dbd SystemNavigator.pop can pop w/o UINavigationController (flutter/engine#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (flutter/engine#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (flutter/engine#6356) c589b31 Expose push/popRoute on FlutterViewController (flutter/engine#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (flutter/engine#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (flutter/engine#6354) 5b79938 Dont make any binaries specify an X11 dependency. (flutter/engine#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (flutter/engine#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (flutter/engine#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (flutter/engine#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278) 9d4b80a Roll src/third_party/skia 17282da3aa94..5767fc042834 (8 commits) (flutter/engine#6348) ef98dcb Add support for counter timeline traces from the engine. (flutter/engine#6315) a961e96 Roll buildroot to pick up updated vs toolchain. (flutter/engine#6346) d6bb599 Fixed IsolateNameServer documentation (flutter/engine#6344) 0c854ac Roll src/third_party/skia bdf1431686c2..17282da3aa94 (4 commits) (flutter/engine#6345) e394ea1 Roll src/third_party/skia c05302bc84da..bdf1431686c2 (1 commits) (flutter/engine#6343) bcdfc23 Roll src/third_party/skia 5457141b011e..c05302bc84da (1 commits) (flutter/engine#6342) a861f37 Pass on the new unsafe-package-serialization option (flutter/engine#6331) 5e77a1e Roll src/third_party/skia bd03b54cb98d..5457141b011e (1 commits) (flutter/engine#6340) 6332db8 Roll src/third_party/skia f18c297cfb74..bd03b54cb98d (1 commits) (flutter/engine#6338) a08bc52 Roll src/third_party/skia 7ffa40cedbc4..f18c297cfb74 (6 commits) (flutter/engine#6336) 8247ce2 Implement restore functions on Android and iOS (flutter/engine#6322) 2ead5c0 Roll src/third_party/skia 4ef464cd3c2e..7ffa40cedbc4 (10 commits) (flutter/engine#6334) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@9d4b80a...5ae4708 git log 9d4b80a..5ae4708 --no-merges --oneline 5ae4708 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (flutter/engine#6360) 763627f Do not export libdart symbols (flutter/engine#6337) 3052dbd SystemNavigator.pop can pop w/o UINavigationController (flutter/engine#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (flutter/engine#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (flutter/engine#6356) c589b31 Expose push/popRoute on FlutterViewController (flutter/engine#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (flutter/engine#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (flutter/engine#6354) 5b79938 Dont make any binaries specify an X11 dependency. (flutter/engine#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (flutter/engine#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (flutter/engine#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (flutter/engine#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@9d4b80a...3a01f39 git log 9d4b80a..3a01f39 --no-merges --oneline 3a01f39 Change log level from ERROR to WARNING (flutter/engine#6361) 5ae4708 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (flutter/engine#6360) 763627f Do not export libdart symbols (flutter/engine#6337) 3052dbd SystemNavigator.pop can pop w/o UINavigationController (flutter/engine#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (flutter/engine#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (flutter/engine#6356) c589b31 Expose push/popRoute on FlutterViewController (flutter/engine#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (flutter/engine#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (flutter/engine#6354) 5b79938 Dont make any binaries specify an X11 dependency. (flutter/engine#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (flutter/engine#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (flutter/engine#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (flutter/engine#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@9d4b80a...edf6249 git log 9d4b80a..edf6249 --no-merges --oneline edf6249 Add pushOffset to SceneBuilder (flutter/engine#6349) 3a01f39 Change log level from ERROR to WARNING (flutter/engine#6361) 5ae4708 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (flutter/engine#6360) 763627f Do not export libdart symbols (flutter/engine#6337) 3052dbd SystemNavigator.pop can pop w/o UINavigationController (flutter/engine#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (flutter/engine#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (flutter/engine#6356) c589b31 Expose push/popRoute on FlutterViewController (flutter/engine#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (flutter/engine#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (flutter/engine#6354) 5b79938 Dont make any binaries specify an X11 dependency. (flutter/engine#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (flutter/engine#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (flutter/engine#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (flutter/engine#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
flutter/engine@9d4b80a...d80c1de git log 9d4b80a..d80c1de --no-merges --oneline d80c1de Roll src/third_party/skia ab3144c3abb9..656cefe65d62 (11 commits) (flutter/engine#6362) edf6249 Add pushOffset to SceneBuilder (flutter/engine#6349) 3a01f39 Change log level from ERROR to WARNING (flutter/engine#6361) 5ae4708 Roll src/third_party/skia 227d4e10276c..ab3144c3abb9 (11 commits) (flutter/engine#6360) 763627f Do not export libdart symbols (flutter/engine#6337) 3052dbd SystemNavigator.pop can pop w/o UINavigationController (flutter/engine#6341) 0c096f7 Roll src/third_party/skia b3e48afc936d..227d4e10276c (1 commits) (flutter/engine#6359) b8c2a17 Roll src/third_party/skia cfe1264d7465..b3e48afc936d (3 commits) (flutter/engine#6356) c589b31 Expose push/popRoute on FlutterViewController (flutter/engine#6347) 075b3fc Roll src/third_party/skia 5ea41fc89b26..cfe1264d7465 (1 commits) (flutter/engine#6355) 2dd9b99 Roll Dart to version 808ed6238b9262660e31ea826f7aea6cfa3a3493 (flutter/engine#6354) 5b79938 Dont make any binaries specify an X11 dependency. (flutter/engine#6353) 309ac4e V0.8.2 fix compile problem with xcode10 (flutter/engine#6339) 26fdd1e Roll src/third_party/skia 5767fc042834..5ea41fc89b26 (3 commits) (flutter/engine#6351) cc44ca5 Perform persistent cache stores on the IO thread outside the frame workload. (flutter/engine#6350) f2a3df9 Wire up the Skia persistent GPU related artifacts cache. (flutter/engine#6278) The AutoRoll server is located here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+/master/autoroll/README.md If the roll is causing failures, please contact the current sheriff, who should be CC'd on the roll, and stop the roller if necessary.
* SystemNavigator.pop can pop w/o UINavigationController
Today, iOS apps in Flutter ignore System.pop unless they find that the
rootViewController
is aUINavigationViewController
.For Add2App, it's entirely possible someone will show the view using something like
showDetailViewController
fromUIViewController
. This patch updates the logic to handle that scenario, but to do so theFlutterPlatformPlugin
needs to get access to theFlutterViewController
, and to do that I added functionality there forFlutterViewController
to createWeakPtr
s.I'd be very happy if it turns out there's a way to stack allocate the
WeakPtrFactory
(or equivalent functionality) in Objective C++./cc @matthew-carroll - It might be worth investigating how
SystemNavigator.pop
is working in Android's Add2App use casesFixes part of flutter/flutter#22054