Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Added a log message when sharing a FlutterEngine across multiple FlutterViewControllers. #17186

Merged
merged 4 commits into from
Mar 23, 2020

Conversation

gaaclarke
Copy link
Member

@gaaclarke gaaclarke requested a review from xster March 17, 2020 19:02
@xster
Copy link
Member

xster commented Mar 17, 2020

Add to https://cs.opensource.google/flutter/engine/+/master:shell/platform/darwin/ios/framework/Headers/FlutterViewController.h;l=59 as well. e.g. if you give me FlutterEngine that's already used, we'll crash (we don't have to do it in the implementation right now but we should at some point).

@@ -144,6 +144,11 @@ - (instancetype)initWithEngine:(FlutterEngine*)engine
self = [super initWithNibName:nibName bundle:nibBundle];
if (self) {
_viewOpaque = YES;
if (engine.viewController) {
FML_LOG(ERROR) << "Attempting to share a FlutterEngine across multiple "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The supplied FlutterEngine << engine << is already used with FlutterViewController instance << engine.ViewController <<. One instance of the FlutterEngine can only be attached to one FlutterViewController at a time. Set FlutterEngine.viewController to nil before attaching it to another FlutterViewController.

While on this topic, should we do this automatically in the FlutterViewController's dealloc too? Unsetting the engine's viewController property.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While on this topic, should we do this automatically in the FlutterViewController's dealloc too? Unsetting the engine's viewController property.

That already happens, niling out an engine's view controller with their view controller is dealloc'd.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

message updated.

@gaaclarke gaaclarke requested a review from xster March 18, 2020 18:00
@gaaclarke
Copy link
Member Author

landing, previously only failed formatting, now it's passing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants