Commit 7d797fa7 authored by 余玠's avatar 余玠

Merge branch 'feature/boost_for_taobao'

# Conflicts:
#	example/ios/Runner/AppDelegate.h
#	ios/Classes/container/FLBFlutterViewContainer.m
parents fb1f6ed2 bbf1e390
...@@ -125,5 +125,12 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -125,5 +125,12 @@ NS_ASSUME_NONNULL_BEGIN
exts:(NSDictionary *)exts exts:(NSDictionary *)exts
onPageFinished:(void (^)(NSDictionary *))resultCallback onPageFinished:(void (^)(NSDictionary *))resultCallback
completion:(void (^)(BOOL))completion; completion:(void (^)(BOOL))completion;
//切记:在destroyPluginContext前务必将所有FlutterViewController及其子类的实例销毁。在这里是FLBFlutterViewContainer。否则会异常;以下是全部步骤
//1. 首先通过为所有FlutterPlugin的methodChannel属性设为nil来解除其与FlutterEngine的间接强引用
//2. 销毁所有的FlutterViewController实例(或保证所有FlutterVC已经退出),来解除其与FlutterEngine的强引用,在每个VC卸载的时候FlutterEngine会调用destroyContext
//3. 调用FlutterBoostPlugin.destroyPluginContext函数来解除与其内部context的强引用。内部持有的FlutterEngine也会被卸载(非外部传入的情形)
//4. 如果是外部传入的FlutterEngine,需要外部自己释放
- (void)destroyPluginContext;
@end @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
...@@ -130,8 +130,8 @@ ...@@ -130,8 +130,8 @@
__weak __typeof__(self) weakSelf = self; __weak __typeof__(self) weakSelf = self;
dispatch_once(&onceToken, ^{ dispatch_once(&onceToken, ^{
__strong __typeof__(weakSelf) self = weakSelf; __strong __typeof__(weakSelf) self = weakSelf;
self.factory = FLBFactory.new; FLBFactory *factory = FLBFactory.new;
self.application = [self->_factory createApplication:platform]; self.application = [factory createApplication:platform];
[self.application startFlutterWithPlatform:platform [self.application startFlutterWithPlatform:platform
withEngine:engine withEngine:engine
onStart:callback]; onStart:callback];
...@@ -182,4 +182,9 @@ ...@@ -182,4 +182,9 @@
id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application]; id<FLBFlutterApplicationInterface> app = [[FlutterBoostPlugin sharedInstance] application];
[app close:uniqueId result:resultData exts:exts completion:completion]; [app close:uniqueId result:resultData exts:exts completion:completion];
} }
- (void)destroyPluginContext{
self.methodChannel = nil;
self.application = nil;
}
@end @end
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#import "FlutterBoostPlugin.h" #import "FlutterBoostPlugin.h"
@interface FlutterBoostPlugin() @interface FlutterBoostPlugin()
@property (nonatomic,strong) id<FLBFlutterApplicationInterface> application; @property (nonatomic,strong) id<FLBFlutterApplicationInterface> application;
@property (nonatomic,strong) id<FLBAbstractFactory> factory;
@property (nonatomic,strong) FlutterMethodChannel *methodChannel; @property (nonatomic,strong) FlutterMethodChannel *methodChannel;
@property (nonatomic,copy) NSString *fPageId; @property (nonatomic,copy) NSString *fPageId;
@property (nonatomic,copy) NSString *fPagename; @property (nonatomic,copy) NSString *fPagename;
......
...@@ -105,11 +105,6 @@ ...@@ -105,11 +105,6 @@
arguments:@{@"type":@"foreground"}]; arguments:@{@"type":@"foreground"}];
} }
- (FlutterEngine *)engine
{
return _engine;
}
- (void)atacheToViewController:(FlutterViewController *)vc - (void)atacheToViewController:(FlutterViewController *)vc
{ {
if(_engine.viewController != vc){ if(_engine.viewController != vc){
...@@ -132,5 +127,8 @@ ...@@ -132,5 +127,8 @@
// [self detach]; // [self detach];
} }
- (void)dealloc{
[self.engine setViewController:nil];
}
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment