wuba / Fair

A Flutter package used to update widget tree dynamically. Fair提供一整套Flutter动态化解决方案
https://fair.58.com
BSD 3-Clause "New" or "Revised" License
2.64k stars 314 forks source link

ios调用plugin方法失败:FairJSBridge.m exceptionValue:ReferenceError: Cannot access uninitialized variable. #137

Open guyuuan opened 2 years ago

guyuuan commented 2 years ago

问题

在ios使用plugin调用dart侧方法报错,在Android可以正常调用

环境信息

提供Fair版本号

dependencies:
  fair: 2.7.0

相关截图【可选】

[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke, 
    Line:87 >>
    {"pageName":"plugin_test#0","type":"method","args":{"funcName":"_onPressed","args":null}}
[Fair]:
    File:FairJSBridge.m, 
    Function:-[FairJSBridge context]_block_invoke, 
    Line:220 >>
    exceptionValue:ReferenceError: Cannot access uninitialized variable.
[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    Line:92 >>
    undefined
[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    Line:96 >>
    undefined
yancechen commented 2 years ago

收到,我们排查一下~

cuocuo commented 2 years ago

同样的问题,请问有解决吗? @yancechen

yancechen commented 2 years ago

还在排查中。

xiangwc commented 2 years ago

问题

在ios使用plugin调用dart侧方法报错,在Android可以正常调用

环境信息

提供Fair版本号

dependencies:
  fair: 2.7.0

相关截图【可选】

[Fair]:
  File:FairDartBridge.m, 
  Function:-[FairDartBridge setDartListener]_block_invoke, 
  Line:87 >>
  {"pageName":"plugin_test#0","type":"method","args":{"funcName":"_onPressed","args":null}}
[Fair]:
  File:FairJSBridge.m, 
  Function:-[FairJSBridge context]_block_invoke, 
  Line:220 >>
  exceptionValue:ReferenceError: Cannot access uninitialized variable.
[Fair]:
  File:FairDartBridge.m, 
  Function:-[FairDartBridge setDartListener]_block_invoke_2, 
  Line:92 >>
  undefined
[Fair]:
  File:FairDartBridge.m, 
  Function:-[FairDartBridge setDartListener]_block_invoke_2, 
  Line:96 >>
  undefined

能提供一下出错的代码吗?

cuocuo commented 2 years ago

问题 在ios使用plugin调用dart侧方法报错,在Android可以正常调用 环境信息 提供Fair版本号

dependencies:
  fair: 2.7.0

相关截图【可选】

[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke, 
    Line:87 >>
    {"pageName":"plugin_test#0","type":"method","args":{"funcName":"_onPressed","args":null}}
[Fair]:
    File:FairJSBridge.m, 
    Function:-[FairJSBridge context]_block_invoke, 
    Line:220 >>
    exceptionValue:ReferenceError: Cannot access uninitialized variable.
[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    Line:92 >>
    undefined
[Fair]:
    File:FairDartBridge.m, 
    Function:-[FairDartBridge setDartListener]_block_invoke_2, 
    Line:96 >>
    undefined

能提供一下出错的代码吗?

大概定位到问题了。fair_jsbase.js文件中有bigint类型在iOS14一下的系统上是不支持的,导致了加载js文件失败。我在iOS15系统上就可以跑通,iOS12的系统就会报错。 https://webkit.org/blog/11340/new-webkit-features-in-safari-14/ https://caniuse.com/bigint 这两个文章都有对bigint的支持有说明! @zhiqingchen

cuocuo commented 2 years ago

这个可以先用其他类型替换BigInt吗,BigInt类型目前兼容性不好! @yancechen

LynkKid commented 2 years ago

I am also facing the same error, please help me to solve it

[Fair]: File:FairDartBridge.m, Function:-[FairDartBridge setDartListener]_block_invoke, Line:87 >> {"pageName":"null#2","type":"method","args":{"funcName":"onBack","args":null}} [Fair]: File:FairJSBridge.m, Function:-[FairJSBridge context]_block_invoke, Line:220 >> exceptionValue:TypeError: undefined is not an object (evaluating 'mClass[funcName]') [Fair]: File:FairDartBridge.m, Function:-[FairDartBridge setDartListener]_block_invoke_2, Line:92 >> undefined [Fair]: File:FairDartBridge.m, Function:-[FairDartBridge setDartListener]_block_invoke_2, Line:96 >> undefined