Keep engine alive if VC is not deallocated (#7544)

This commit is contained in:
Dan Field 2019-01-22 15:03:25 -08:00 committed by GitHub
parent 88fee0804c
commit 2123d3a569
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 3 deletions

View File

@ -144,13 +144,15 @@
FML_DCHECK(self.iosPlatformView);
_viewController = [viewController getWeakPtr];
self.iosPlatformView->SetOwnerViewController(_viewController);
if (!viewController && !_allowHeadlessExecution) {
[self maybeSetupPlatformViewChannels];
}
- (void)notifyViewControllerDeallocated {
if (!_allowHeadlessExecution) {
[self resetChannels];
_shell.reset();
_threadHost.Reset();
} else {
[self maybeSetupPlatformViewChannels];
}
}

View File

@ -43,6 +43,7 @@
- (FlutterTextInputPlugin*)textInputPlugin;
- (void)launchEngine:(NSString*)entrypoint libraryURI:(NSString*)libraryOrNil;
- (BOOL)createShell:(NSString*)entrypoint libraryURI:(NSString*)libraryOrNil;
- (void)notifyViewControllerDeallocated;
@end

View File

@ -430,6 +430,7 @@
}
- (void)dealloc {
[_engine.get() notifyViewControllerDeallocated];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}