Commit 0d11a6a2 authored by 卢克's avatar 卢克 Committed by Luke

修复部分场景下的crash问题

1. 当存在tab为flutter vc的情况,切换到首页后,tab的flutter vc其还是live的状态,当回到首页点击进入某个flutter vc,然后回到首页之后,这个时候进行前后台切换,tab的flutter vc会进行active的回调,进行surfaceUpdated操作,但是这个时候engine.viewController并不是这个tab的flutter vc,会产生crash
2. 当退出某个flutter vc的时候之前可能是为了时许问题不影响别的已经设置好的engine.viewController所以没有进行detatch操作,这样会有可能导致最后退出的lutter vc不能及时释放
parent 27877dca
......@@ -30,7 +30,6 @@
@interface FLBFlutterEngine()
@property (nonatomic,strong) FlutterEngine *engine;
@property (nonatomic,strong) FLBFlutterViewContainer *dummy;
@end
@implementation FLBFlutterEngine
......@@ -53,10 +52,6 @@
}else{
[_engine runWithEntrypoint:nil];
}
// _dummy = [[FLBFlutterViewContainer alloc] initWithEngine:_engine
// nibName:nil
// bundle:nil];
// _dummy.name = kIgnoreMessageWithName;
}
return self;
......@@ -108,9 +103,9 @@
- (void)detach
{
if(_engine.viewController != _dummy){
if(_engine.viewController != nil){
[(FLBFlutterViewContainer *)_engine.viewController surfaceUpdated:NO];
_engine.viewController = _dummy;
_engine.viewController = nil;
}
}
......
......@@ -38,6 +38,7 @@
- (void)flushOngoingTouches;
- (void)bridge_viewDidDisappear:(BOOL)animated;
- (void)bridge_viewWillAppear:(BOOL)animated;
- (void)surfaceUpdated:(BOOL)appeared;
@end
#pragma clang diagnostic push
......@@ -223,6 +224,12 @@ static NSUInteger kInstanceCounter = 0;
[FLUTTER_APP.flutterProvider detach];
}
- (void)surfaceUpdated:(BOOL)appeared {
if (self.engine && self.engine.viewController == self) {
[super surfaceUpdated:appeared];
}
}
#pragma mark - Life circle methods
- (void)viewDidLayoutSubviews
......@@ -288,6 +295,10 @@ static NSUInteger kInstanceCounter = 0;
params:_params
uniqueId:self.uniqueIDString];
[super bridge_viewDidDisappear:animated];
if (self.engine.viewController == self) {
[self detatchFlutterEngine];
}
}
- (void)installSplashScreenViewIfNecessary {
......
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