Flutter开发HarmonyOS鸿蒙Next应用的时候PlatformView嵌套webview二次进入白屏如何解决
Flutter开发HarmonyOS鸿蒙Next应用的时候PlatformView嵌套webview二次进入白屏如何解决
【模块名_概率】简要描述:
webview_flutter使用最新版本 8a12da420c141f35f1e45dc5f1763bf96def24f1(6-24号),发现EmbeddingNodeController报错Cannot convert a NULL value to a JSObject,详细信息见最后。
【环境信息】:
- 网络环境 WiFi
- 硬件开发板型号 DevDco 5.0.401(HarmonyOS-NEXT-DB1) Huawei mate 60 pro(3.0.0.22)
- 软件版本信息或tag节点 flutter_flutter版本是5d5b44473f67eee60bc992b127b54f7562fee2ab (6-24号)
- 测试环境
- 其他
【预置条件】:
【测试步骤】:
【预期结果】:
【实际结果】:
【恢复手段】:
【出现概率】:问题出现次数/实际测试次数
【定位信息】:
-
- Log、截图、多媒体文件等,所有和问题有关的信息: 详细堆栈如下: Pid:27107 Uid:20020095 Reason:TypeError Error name:TypeError Error message:Cannot convert a NULL value to a JSObject Stacktrace: at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4804:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4789:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4789:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at getDeepCopyOfObjectRecursive (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4806:1) at deepCopyObjectInternal (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4760:4760) at deepCopyObject (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4740:4740) at copyObject (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4690:4690) at resetLocalValue (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4655:1) at SynchedPropertyOneWayPU (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:4480:4480) at SynchedPropertyObjectOneWayPU (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:0:1) at OhosWebView (oh_modules/.ohpm/webview_flutter_ohos@5hznstjvzq4wi9+vqbx0+faahgc=/oh_modules/webview_flutter_ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets:23:1) at anonymous (oh_modules/.ohpm/webview_flutter_ohos@5hznstjvzq4wi9+vqbx0+faahgc=/oh_modules/webview_flutter_ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets:79:34) at updateFunc (…/…/…/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:199:199) at observeComponentCreation2 (…/…/…/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:215:1) at WebBuilder (oh_modules/.ohpm/webview_flutter_ohos@5hznstjvzq4wi9+vqbx0+faahgc=/oh_modules/webview_flutter_ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets:79:34) at build (…/…/…/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:132:132) at build (…/…/…/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/jsXNode.js:65:65) at makeNode (oh_modules/.ohpm/@ohos+flutter_ohos@th5lkruchr3xfp03wqewvuecaci=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/ohos/EmbeddingNodeController.ets:57:7) at anonymous (oh_modules/.ohpm/@ohos+flutter_ohos@th5lkruchr3xfp03wqewvuecaci=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/ohos/FlutterPage.ets:56:7) at updateFunc (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:6025:6025) at UpdateElement (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:5665:5665) at anonymous (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:5927:5927) at updateDirtyElements (/usr1/hmos_for_system/src/increment/sourcecode/foundation/arkui/ace_engine/frameworks/bridge/declarative_frontend/engine/stateMgmt.js:5922:5922) at rerender (oh_modules/.ohpm/@ohos+flutter_ohos@th5lkruchr3xfp03wqewvuecaci=/oh_modules/@ohos/flutter_ohos/src/main/ets/embedding/ohos/FlutterPage.ets:196:9) at (oh_modules/.ohpm/webview_flutter_ohos@5hznstjvzq4wi9+vqbx0+faahgc=/oh_modules/webview_flutter_ohos/src/main/ets/io.flutter.plugins/webview_flutter/OhosWebView.ets:80)
在Flutter开发HarmonyOS鸿蒙Next应用时,遇到PlatformView嵌套WebView二次进入白屏的问题,通常可能是由于WebView的状态管理或生命周期处理不当引起的。以下是一些可能的解决方案:
-
确保WebView正确释放:在Flutter的Widget生命周期中,确保在适当的时机(如
dispose
方法)释放WebView资源,避免资源泄露或重复初始化。 -
维护WebView状态:在嵌套WebView时,考虑使用状态管理(如Flutter的Provider、Riverpod等)来维护WebView的状态,确保在不同页面或组件间切换时WebView的状态得以保留。
-
检查平台通道:PlatformView通过平台通道与原生代码通信,检查这些通道是否在所有情况下都能正确建立和关闭,特别是在页面切换时。
-
优化WebView初始化:避免在每次进入页面时都重新初始化WebView,可以尝试在页面首次加载时初始化,后续仅更新URL或内容。
-
调试和日志:增加详细的日志输出,以便跟踪WebView的加载、渲染和销毁过程,定位问题所在。
如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html