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

This commit is contained in:
Dan Field
2019-01-22 15:03:25 -08:00
committed by GitHub
parent e2884a11f1
commit 8d6ec47a36
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];
}