Commit 208afc9e authored by 余玠's avatar 余玠

精简代码,避免过多的surfaceUpdate,原因:

1. surfaceUpdate会线程等待,在低端机上会卡顿
2. 没必要有dummy VC
parent b0aa14f9
...@@ -49,10 +49,11 @@ ...@@ -49,10 +49,11 @@
}else{ }else{
[_engine runWithEntrypoint:nil]; [_engine runWithEntrypoint:nil];
} }
_dummy = [[FLB2FlutterViewContainer alloc] initWithEngine:_engine _dummy = nil;
nibName:nil // _dummy = [[FLB2FlutterViewContainer alloc] initWithEngine:_engine
bundle:nil]; // nibName:nil
_dummy.name = kIgnoreMessageWithName; // bundle:nil];
// _dummy.name = kIgnoreMessageWithName;
Class clazz = NSClassFromString(@"GeneratedPluginRegistrant"); Class clazz = NSClassFromString(@"GeneratedPluginRegistrant");
if (clazz) { if (clazz) {
...@@ -81,7 +82,7 @@ ...@@ -81,7 +82,7 @@
- (void)resume - (void)resume
{ {
[[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"]; [[_engine lifecycleChannel] sendMessage:@"AppLifecycleState.resumed"];
[(FLB2FlutterViewContainer *)_engine.viewController surfaceUpdated:YES]; // [(FLB2FlutterViewContainer *)_engine.viewController surfaceUpdated:YES];
} }
- (void)inactive - (void)inactive
...@@ -126,9 +127,12 @@ ...@@ -126,9 +127,12 @@
// if ([_dummy respondsToSelector:@selector(setEnableForRunnersBatch:)]) { // if ([_dummy respondsToSelector:@selector(setEnableForRunnersBatch:)]) {
// [_dummy setEnableForRunnersBatch:YES]; // [_dummy setEnableForRunnersBatch:YES];
// } // }
[self detach]; // [self detach];
[_dummy surfaceUpdated:YES]; // [_dummy surfaceUpdated:YES];
} }
- (void)dealloc{
[self.engine setViewController:nil];
}
@end @end
...@@ -155,16 +155,6 @@ static NSUInteger kInstanceCounter = 0; ...@@ -155,16 +155,6 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
if([FLUTTER_APP contains:self]){
[self surfaceUpdated:NO];
[self detatchFlutterEngine];
}else{
[self attatchFlutterEngine];
[self surfaceUpdated:YES];
}
[FLUTTER_APP resume];
//For new page we should attach flutter view in view will appear //For new page we should attach flutter view in view will appear
//for better performance. //for better performance.
...@@ -188,13 +178,13 @@ static NSUInteger kInstanceCounter = 0; ...@@ -188,13 +178,13 @@ static NSUInteger kInstanceCounter = 0;
//Ensure flutter view is attached. //Ensure flutter view is attached.
[self attatchFlutterEngine]; [self attatchFlutterEngine];
[FLUTTER_APP resume];
[BoostMessageChannel didShowPageContainer:^(NSNumber *result) {} [BoostMessageChannel didShowPageContainer:^(NSNumber *result) {}
pageName:_name pageName:_name
params:_params params:_params
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
//NOTES:务必在show之后再update,否则有闪烁
[self surfaceUpdated:YES];
[super viewDidAppear:animated]; [super viewDidAppear:animated];
} }
...@@ -211,13 +201,11 @@ static NSUInteger kInstanceCounter = 0; ...@@ -211,13 +201,11 @@ static NSUInteger kInstanceCounter = 0;
- (void)viewDidDisappear:(BOOL)animated - (void)viewDidDisappear:(BOOL)animated
{ {
[FLUTTER_APP resume];
[BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {} [BoostMessageChannel didDisappearPageContainer:^(NSNumber *result) {}
pageName:_name pageName:_name
params:_params params:_params
uniqueId:self.uniqueIDString]; uniqueId:self.uniqueIDString];
[super viewDidDisappear:animated]; [super viewDidDisappear:animated];
[FLUTTER_APP resume];
} }
......
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