mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Provide public api to allow FlutterEngine related context to be destoryed (flutter/engine#7610)
Provide public api to allow FlutterEngine related context to be destoryed.
This commit is contained in:
parent
284016b1e1
commit
e6b2d000dd
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user