未验证 提交 90569e84 编写于 作者: K KyleWong 提交者: GitHub

Provide public api to allow FlutterEngine related context to be destoryed (#7610)

Provide public api to allow FlutterEngine related context  to be destoryed.
上级 693645e4
......@@ -50,6 +50,10 @@ FLUTTER_EXPORT
* A newly initialized engine will not run the `FlutterDartProject` until either
* `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI:` is called.
*
* FlutterEngine created with this method will have allowHeadlessExecution set to `YES`.
* This means that the engine will continue to run regardless of whether a `FlutterViewController`
* is attached to it or not, until `-destroyContext:` is called or the process finishes.
*
* @param labelPrefix The label prefix used to identify threads for this instance. Should
* be unique across FlutterEngine instances, and is used in instrumentation to label
* the threads used by this FlutterEngine.
......@@ -119,6 +123,16 @@ FLUTTER_EXPORT
*/
- (BOOL)runWithEntrypoint:(NSString*)entrypoint libraryURI:(NSString*)uri;
/**
* Destroy running context for an engine.
*
* This method can be used to force the FlutterEngine object to release all resources.
* After sending this message, the object will be in an unusable state until it is deallocated.
* Accessing properties or sending messages to it will result in undefined behavior or runtime
* errors.
*/
- (void)destroyContext;
/**
* Sets the `FlutterViewController` for this instance. The FlutterEngine must be
* running (e.g. a successful call to `-runWithEntrypoint:` or `-runWithEntrypoint:libraryURI`)
......
......@@ -149,13 +149,16 @@
- (void)notifyViewControllerDeallocated {
if (!_allowHeadlessExecution) {
[self resetChannels];
_shell.reset();
_threadHost.Reset();
[self destroyContext];
}
}
- (void)destroyContext {
[self resetChannels];
_shell.reset();
_threadHost.Reset();
}
- (FlutterViewController*)viewController {
if (!_viewController) {
return nil;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册