Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'container != null': is not true. #1607

Open
JDongKhan opened this issue Mar 8, 2022 · 5 comments
Open

'container != null': is not true. #1607

JDongKhan opened this issue Mar 8, 2022 · 5 comments

Comments

@JDongKhan
Copy link

flutterboost集成到Android原生项目中,flutter页面首次显示会报下面的错误。

flutter boost版本:v3.0-release.1
flutter sdk:2.5.3

之前使用的是v3.0-release没有这个问题
═══════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
'package:flutter_boost/src/boost_lifecycle_binding.dart': Failed assertion: line 96 pos 12:
'container != null': is not true.
When the exception was thrown, this was the stack:
#2 BoostLifecycleBinding.containerDidShow (package:flutter_boost/src/boost_lifecycle_binding.dart:96:12)
I/flutter: #3 FlutterBoostAppState.onContainerShow (package:flutter_boost/src/flutter_boost_app.dart:635:36)
#4 BoostFlutterRouterApi.onContainerShow. (package:flutter_boost/src/boost_flutter_router_api.dart:74:16)
#5 BoostOperationQueue.runPendingOperations (package:flutter_boost/src/boost_operation_queue.dart:23:17)
#6 FlutterBoostAppState.initState. (package:flutter_boost/src/flutter_boost_app.dart:108:36)
#7 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1143:15)
#8 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1088:9)
#9 SchedulerBinding.scheduleWarmUpFrame. (package:flutter/src/scheduler/binding.dart:863:7)
(elided 13 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, dart:async, and dart:async-patch)
══════════════════════════════════════════════════════════

@JDongKhan
Copy link
Author

JDongKhan commented Mar 8, 2022

因为刚使用flutter boost,对里面的逻辑不是很熟,通过在onContainerShow 方法debug发现第一次显示的时候确实没有找到container。 追踪了下先调了pushWithInterceptor,而里面的pushContainer比onContainerShow会慢,导致了onContainerShow的时候还页面信息还没有塞进去

@JDongKhan
Copy link
Author

经过多次定位,将BoostFlutterRouterApi的pushRoute方法内容改为下面就好了
@override Future<void> pushRoute(CommonParams arg) { return appState.pushWithInterceptor( arg.pageName, true /* isFromHost */, true /* isFlutterPage */, withContainer: true, uniqueId: arg.uniqueId, arguments: Map<String, dynamic>.from(arg.arguments ?? <String, dynamic>{})); }

感觉像是_addInOperationQueueOrExcute异步了。

我同样的环境跑example里面的项目没问题,写个空的AndroidDemo,然后以module的形式集成进去就不行。iOS也没有问题,不知道是不是什么环境导致了异样的表现。 简单的对比了下就下面一点不一样
environment: sdk: ">=2.0.0-dev.68.0 <3.0.0"

@shingohu
Copy link

一样的升级到v3.0-release.1 就会报错,也是add-to-app的方式集成

@wkkun
Copy link

wkkun commented Mar 28, 2022

近期的一次提交 解决这个问题,
pushRoute(uniqueId, container.getUrl(), container.getUrlParams(), reply -> {
onContainerShow(uniqueId);
});

@shingohu
Copy link

iOS也有这个问题啊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants