iOS端,首次启动后,当第一次从一个weex页面跳转到flutter页面的时候,如果跳转后移除weex页面,页面会卡死。
在页面的生命周期里,会调用
[self surfaceUpdated:YES];
进行视图更新。
当第一次从一个weex页面跳转到flutter页面,并移除weex页面的时候,viewDidAppear会频繁触发,导致surfaceUpdated被多次调用。
解决方法,添加标记,防止viewDidAppear被多次触发导致频繁调用surfaceUpdated:
- (void)viewDidAppear:(BOOL)animated
{
//Ensure flutter view is attached.
[self attatchFlutterEngine];
//根据淘宝特价版日志证明,即使在UIViewController的viewDidAppear下,application也可能在inactive模式,此时如果提交渲染会导致GPU后台渲染而crash
//参考:https://github.com/flutter/flutter/issues/57973
//https://github.com/flutter/engine/pull/18742
if([UIApplication sharedApplication].applicationState == UIApplicationStateActive && _isNotFirst){
//NOTES:务必在show之后再update,否则有闪烁; 或导致侧滑返回时上一个页面会和top页面内容一样
[self surfaceUpdated:YES];
} else {
_isNotFirst = true;
}
[super viewDidAppear:animated];
// Enable or disable pop gesture
// note: if disablePopGesture is nil, do nothing
if (self.disablePopGesture) {
self.navigationController.interactivePopGestureRecognizer.enabled = ![self.disablePopGesture boolValue];
}
[FB_PLUGIN containerAppeared:self];
}