alibaba / flutter_boost

FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts
https://github.com/alibaba/flutter_boost
MIT License
6.98k stars 1.23k forks source link

beta.5修复的问题,beta.6又出现了【NativeRouterApi.getStackFromHost -> StackInfo.decode 出现NoSuchMethodError异常】 #1206

Closed 1992zhangbo closed 3 years ago

1992zhangbo commented 3 years ago
- v3.0-beta.11
- Android Studio & iOS模拟器 运行Module代码 或者 Xcode运行项目
- iOS12

nativeRouterApi.getStackFromHost()经过Flutter -> OC -> Fluttter数据交互后,调用了null,出现NoSuchMethodError 异常。

https://github.com/alibaba/flutter_boost/issues/1025

在close的issue中看到有同学反馈了此问题,并在v3.0-beta.5中已修复,可是v3.0-beta.6中代码被覆盖为旧代码,目前v3.0-beta.11中依然存在,请开发大大看下

wing3501 commented 3 years ago

这两个方法执行顺序有问题。 saveStackToHost和getStackFromHost 在我的工程里就是会先去getStackFromHost导致错误

堆栈 [VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null. Receiver: null Tried calling: Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5) StackInfo.decode package:flutter_boost/messages.dart:46 NativeRouterApi.getStackFromHost package:flutter_boost/messages.dart:264

FlutterBoostAppState._restoreStackForHotRestart package:flutter_boost/flutter_boost_app.dart:163 在example工程里就会先执行saveStackToHost,所以pigeonMap有值。 堆栈: flutter: FlutterBoost#page_visibility, #addGlobalObserver, Instance of 'AppGlobalPageVisibilityObserver' flutter: FlutterBoost#boost_lifecycle: BoostLifecycleBinding.containerDidPush flutter: FlutterBoost#page_visibility, #dispatchPageShowEvent, tab_friend flutter: FlutterBoost#boost_lifecycle: AppGlobalPageVisibilityObserver.onPageCreate route:tab_friend flutter: FlutterBoost#page_visibility, #dispatchGlobalPageCreateEvent, tab_friend flutter: FlutterBoost#push page, uniqueId=0BC4569A-3E66-45AB-91DE-969DBA6BD04E, existed=null, withContainer=true, arguments:{}, [Instance of 'BoostContainer', Instance of 'BoostContainer'] flutter: FlutterBoost#_saveStackForHotRestart, [1623404056872_/, 0BC4569A-3E66-45AB-91DE-969DBA6BD04E], {0BC4569A-3E66-45AB-91DE-969DBA6BD04E: [{pageName: tab_friend, uniqueId: 0BC4569A-3E66-45AB-91DE-969DBA6BD04E, arguments: {}}]} flutter: FlutterBoost#push page, uniqueId=0BC4569A-3E66-45AB-91DE-969DBA6BD04E, existed=Instance of 'BoostContainer', withContainer=true, arguments:{}, [Instance of 'BoostContainer', Instance of 'BoostContainer'] flutter: FlutterBoost#_restoreStackForHotRestart, [1623404056872_/, 0BC4569A-3E66-45AB-91DE-969DBA6BD04E], {0BC4569A-3E66-45AB-91DE-969DBA6BD04E: [{uniqueId: 0BC4569A-3E66-45AB-91DE-969DBA6BD04E, arguments: {}, pageName: tab_friend}]} flutter: FlutterBoost#_saveStackForHotRestart, [1623404056872_/, 0BC4569A-3E66-45AB-91DE-969DBA6BD04E], {0BC4569A-3E66-45AB-91DE-969DBA6BD04E: [{pageName: tab_friend, uniqueId: 0BC4569A-3E66-45AB-91DE-969DBA6BD04E, arguments: {}}]}
1992zhangbo commented 3 years ago

在下载的示例工程中,如果在初始化FlutterBoost时,未调用下面的代码就会出现问题。(先去getStackFromHost)

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    省略代码.....
    FBFlutterViewContainer *fvc = FBFlutterViewContainer.new;
    [fvc setName:@"tab_friend" uniqueId:nil params:@{} opaque:YES];
    fvc.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"flutter_tab" image:nil tag:1];
    省略代码......
}

我的使用场景如下: 我在App启动的时候,先进行了FlutterBoost初始化,传递了一些必要的参数。在二级页面触发的时候,才会进行路由跳转。