-
Notifications
You must be signed in to change notification settings - Fork 6k
Conversation
* @param nibBundle The NIB bundle. | ||
*/ | ||
- (instancetype)initWithProject:(nullable FlutterDartProject*)project | ||
withInitialRoute:(nullable NSString*)initialRoute |
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.
s/withInitialRoute/intialRoute
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.
ah yes, agree
@@ -54,6 +55,7 @@ @implementation FlutterEngine { | |||
flutter::ThreadHost _threadHost; | |||
std::unique_ptr<flutter::Shell> _shell; | |||
NSString* _labelPrefix; | |||
NSString* _initialRoute; |
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.
This is leaking, please use a property with copy
semantics.
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.
how do you mean? We're manually copying and releasing it no?
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 releasing of it is conditional. There is still the opportunity for it to leak. It should be cleaned up in the dealloc.
We are copying it, using the property syntax just makes the memory management technique apparent.
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.
Ah understood. PTAL
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.
lookin good
@@ -367,6 +373,12 @@ - (void)setupChannels { | |||
binaryMessenger:self.binaryMessenger | |||
codec:[FlutterJSONMethodCodec sharedInstance]]); | |||
|
|||
if ([_initialRoute length] > 0) { | |||
// Flutter isn't ready to receive this method call yet but the channel buffer will cache this. | |||
[_navigationChannel invokeMethod:@"setInitialRoute" arguments:_initialRoute]; |
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.
You should probably use the variant of invokeMethod that does error checking and print out if there is an error.
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.
oh true. I agree. Though it looks like we're using the non-callback variant across the embedding code currently. I'd like to keep it consistent and move all call sites if we do.
if ([_initialRoute length] > 0) { | ||
// Flutter isn't ready to receive this method call yet but the channel buffer will cache this. | ||
[_navigationChannel invokeMethod:@"setInitialRoute" arguments:_initialRoute]; | ||
[_initialRoute release]; |
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.
Don't release something without niling it out.
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.
ah yes, thanks
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterEngineTest : XCTestCase | ||
@end | ||
|
||
@interface FlutterEngine (Test) <FlutterBinaryMessenger> |
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.
Put this category in a headers so tests don't have to redeclare this.
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.
what implementation style were you thinking? Having something like Source/FlutterEngine.mm
, Source/FlutterEngine_Internal.h
, Source/FlutterEngine_TestFlutterBinaryMessenger.h
, Source/FlutterEngine_TestSomeOtherProtocol.h
, Source/FlutterEngineTest.mm
?
We might end up with a big list since no other test is using this specific category yet (Y(probably)AGNI).
We can also put all "internals" into one header, but it's not very least-privilege-principle.
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.
I think FlutterEngine_Test sounds fine. It would operate like java's visiblefortesting. Everything can just go in there.
I'd say FlutterEngine_Test is like visiblefortesting and FlutterEngine_internal is like package visible methods.
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterEngineTest : XCTestCase | ||
@end | ||
|
||
@interface FlutterEngine (Test) <FlutterBinaryMessenger> | ||
- (void)setBinaryMessenger:binaryMessenger; |
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.
Declare types.
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.
oops, thanks
nibName:(nullable NSString*)nibName | ||
bundle:(nullable NSBundle*)nibBundle { | ||
- (instancetype)initWithProject:(FlutterDartProject*)project | ||
withInitialRoute:(NSString*)initialRoute |
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.
s/withInitialRoute/initialRoute
shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
Outdated
Show resolved
Hide resolved
0AC232F424BA71D300A85907 /* SemanticsObjectTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SemanticsObjectTest.mm; sourceTree = "<group>"; }; | ||
0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = "<group>"; }; | ||
0AC2330324BA71D300A85907 /* accessibility_bridge_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = accessibility_bridge_test.mm; sourceTree = "<group>"; }; | ||
0AC2330B24BA71D300A85907 /* FlutterTextInputPluginTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterTextInputPluginTest.m; sourceTree = "<group>"; }; | ||
0AC2330F24BA71D300A85907 /* FlutterBinaryMessengerRelayTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterBinaryMessengerRelayTest.mm; sourceTree = "<group>"; }; | ||
0AC2331024BA71D300A85907 /* connection_collection_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = connection_collection_test.mm; sourceTree = "<group>"; }; | ||
0AC2331224BA71D300A85907 /* FlutterEnginePlatformViewTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEnginePlatformViewTest.mm; sourceTree = "<group>"; }; | ||
0AC2331924BA71D300A85907 /* FlutterPluginAppLifeCycleDelegateTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterPluginAppLifeCycleDelegateTest.m; sourceTree = "<group>"; }; | ||
0AC2332124BA71D300A85907 /* FlutterViewControllerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterViewControllerTest.mm; sourceTree = "<group>"; }; |
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 for easy navigation? It's hard to read the xcode project. I'm ok with this but jsut a heads up that the less there is in the xcode project the less there is to conflict.
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.
ya, this is pretty optional. I don't feel strongly either way. This is just so people can look at the test they're about to run in this project before they run it (and potentially set breakpoints).
870b9d0
to
93fe293
Compare
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.
Thanks for review. Sorry for the slow turnaround.
* @param nibBundle The NIB bundle. | ||
*/ | ||
- (instancetype)initWithProject:(nullable FlutterDartProject*)project | ||
withInitialRoute:(nullable NSString*)initialRoute |
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.
ah yes, agree
@@ -54,6 +55,7 @@ @implementation FlutterEngine { | |||
flutter::ThreadHost _threadHost; | |||
std::unique_ptr<flutter::Shell> _shell; | |||
NSString* _labelPrefix; | |||
NSString* _initialRoute; |
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.
how do you mean? We're manually copying and releasing it no?
if ([_initialRoute length] > 0) { | ||
// Flutter isn't ready to receive this method call yet but the channel buffer will cache this. | ||
[_navigationChannel invokeMethod:@"setInitialRoute" arguments:_initialRoute]; | ||
[_initialRoute release]; |
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.
ah yes, thanks
@@ -367,6 +373,12 @@ - (void)setupChannels { | |||
binaryMessenger:self.binaryMessenger | |||
codec:[FlutterJSONMethodCodec sharedInstance]]); | |||
|
|||
if ([_initialRoute length] > 0) { | |||
// Flutter isn't ready to receive this method call yet but the channel buffer will cache this. | |||
[_navigationChannel invokeMethod:@"setInitialRoute" arguments:_initialRoute]; |
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.
oh true. I agree. Though it looks like we're using the non-callback variant across the embedding code currently. I'd like to keep it consistent and move all call sites if we do.
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterEngineTest : XCTestCase | ||
@end | ||
|
||
@interface FlutterEngine (Test) <FlutterBinaryMessenger> |
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.
what implementation style were you thinking? Having something like Source/FlutterEngine.mm
, Source/FlutterEngine_Internal.h
, Source/FlutterEngine_TestFlutterBinaryMessenger.h
, Source/FlutterEngine_TestSomeOtherProtocol.h
, Source/FlutterEngineTest.mm
?
We might end up with a big list since no other test is using this specific category yet (Y(probably)AGNI).
We can also put all "internals" into one header, but it's not very least-privilege-principle.
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterEngineTest : XCTestCase | ||
@end | ||
|
||
@interface FlutterEngine (Test) <FlutterBinaryMessenger> | ||
- (void)setBinaryMessenger:binaryMessenger; |
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.
oops, thanks
0AC232F424BA71D300A85907 /* SemanticsObjectTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SemanticsObjectTest.mm; sourceTree = "<group>"; }; | ||
0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = "<group>"; }; | ||
0AC2330324BA71D300A85907 /* accessibility_bridge_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = accessibility_bridge_test.mm; sourceTree = "<group>"; }; | ||
0AC2330B24BA71D300A85907 /* FlutterTextInputPluginTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterTextInputPluginTest.m; sourceTree = "<group>"; }; | ||
0AC2330F24BA71D300A85907 /* FlutterBinaryMessengerRelayTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterBinaryMessengerRelayTest.mm; sourceTree = "<group>"; }; | ||
0AC2331024BA71D300A85907 /* connection_collection_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = connection_collection_test.mm; sourceTree = "<group>"; }; | ||
0AC2331224BA71D300A85907 /* FlutterEnginePlatformViewTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEnginePlatformViewTest.mm; sourceTree = "<group>"; }; | ||
0AC2331924BA71D300A85907 /* FlutterPluginAppLifeCycleDelegateTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterPluginAppLifeCycleDelegateTest.m; sourceTree = "<group>"; }; | ||
0AC2332124BA71D300A85907 /* FlutterViewControllerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterViewControllerTest.mm; sourceTree = "<group>"; }; |
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.
ya, this is pretty optional. I don't feel strongly either way. This is just so people can look at the test they're about to run in this project before they run it (and potentially set breakpoints).
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.
LGTM modulo the initalRoute (potential) leak.
* FlutterDefaultInitialRoute (or nil), it will default to the "/" route. | ||
* @return YES if the call succeeds in creating and running a Flutter Engine instance; NO otherwise. | ||
*/ | ||
- (BOOL)runWithEntrypoint:(nullable NSString*)entrypoint |
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: You still have 2 prepositions in your selector, that's non-standard.
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.
done
6e6a79b
to
4fa79b7
Compare
This pull request is not suitable for automatic merging in its current state.
|
0456c08
to
cf93cc7
Compare
cf93cc7
to
08f4d63
Compare
This pull request is not suitable for automatic merging in its current state.
|
…ants, will need a bigger refactor to clean the build and test script later
This reverts commit 8d08e6c.
Description
Fix flutter/flutter#59895 and persistent UX issues plaguing users with confusing behavior around setInitialRoute.
Deprecate after-the-fact setInitialRoute calls which can easily have no effect. Migrate them as much as possible to constructors.
I'll update the website once this hits stable
Related Issues
Fixes flutter/flutter#59895
Tests
I added the following tests:
Added unit test for engine, integration test for view controller.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.Breaking Change
Did any tests fail when you ran them? Please read handling breaking changes.