wuba/Fair

iOS部分系统调用Plugin报错:FairJSBridge.m,exceptionValue:ReferenceError: Cannot access uninitialized variable.

PeleLee opened this issue · 1 comments

问题

自定义了继承自IFairPlugin的网络请求plugin,在onLoad方法中使用该plugin请求网络数据。iOS真机上运行时大部分机型表现正常,能够用fair加载出请求数据,但有部分机型会报异常,目前已知的有iOS 13.6.1的iPhone 6s真机。

Fair异常信息如下:

[Fair]:
	File:FairDartBridge.m,
	Function:-[FairDartBridge setDartListener]_block_invoke,
	Line:87 >>
	{"pageName":"xxxxWidget#0","type":"method","args":{"funcName":"onLoad","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

结尾附带更详细的日志

环境信息
flutter版本:3.0.5

flutter doctor --verbose信息:

[✓] Flutter (Channel stable, 3.0.5, on macOS 13.1 22C65 darwin-arm, locale zh-Hans-CN)
    • Flutter version 3.0.5 at ~/Other/flutter_sdk/flutter_3.0.5
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (10 months ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at ~/Library/Android/sdk
    • Platform android-33, build-tools 30.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.78.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.62.0

[✓] Connected device (4 available)
    • iPhone (mobile)            • c350852f8e3e64104b0f3d09e157344690b680dd • ios            • iOS 13.6.1 17G80
    • iPhone 14 Pro Max (mobile) • 20FADA25-A6FC-4F93-8C6B-8768AE400C1B     • ios            •
      com.apple.CoreSimulator.SimRuntime.iOS-16-2 (simulator)
    • macOS (desktop)            • macos                                    • darwin-arm64   • macOS 13.1 22C65 darwin-arm
    • Chrome (web)               • chrome                                   • web-javascript • Google Chrome 112.0.5615.137

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Fair版本号

dependencies:
  fair: 3.2.1

复现操作

  1. @FairPatch标记的页面,生成对应的bin资源文件,托管在服务端;
  2. flutter端下载资源文件后,在本地进行加载;
  3. 进入该页面时网络请求逻辑没有执行,可以在控制台看到fair异常日志;

预期结果
所有iOS真机可以正常通过plugin请求接口。

详细日志
目前发现引擎启动时,异常机型的日志会多出一部分,其他都一样:

2023-05-05 16:25:09.224738+0800 Runner[2016:90547] [Fair]:
	File:FairJSBridge.m, 
	Function:-[FairJSBridge context]_block_invoke, 
	Line:220 >>
	exceptionValue:ReferenceError: Can't find variable: BigInt

进入fair页面时,正常机型的日志如下:

[Fair]:
	File:FairDartBridge.m,
	Function:-[FairDartBridge setDartListener]_block_invoke,
	Line:87 >>
	{"pageName":"xxxxWidget#0","type":"method","args":{"funcName":"onLoad","args":null}}
[Fair]:
	File:FairJSBridge.m,
	Function:-[FairJSBridge context]_block_invoke_2,
	Line:229 >>
	CommonPlugin请求参数:{"className":"CommonPlugin#core","funcName":"invokePlugin","pageName":"xxxxWidget#0","request":{"pageName":"xxxxWidget#0","keys":["aaa","bbb"],"callId":"CommonPlugin$1"}}
[Fair]:
	File:FairJSBridge.m,
	Function:-[FairJSBridge context]_block_invoke_2,
	Line:229 >>
	invokeData{"className":"CommonPlugin#core","funcName":"invokePlugin","pageName":"xxxxWidget#0","request":{"pageName":"xxxxWidget#0","keys":["aaa","bbb"],"callId":"CommonPlugin$1"}}
[Fair]:
	File:FairDartBridge.m,
	Function:-[FairDartBridge setDartListener]_block_invoke_2,
	Line:92 >>
	{"pageName":"xxxxWidget#0","result":{}}
[Fair]:
	File:FairDartBridge.m,
	Function:-[FairDartBridge setDartListener]_block_invoke_2,
	Line:96 >>
	{"pageName":"xxxxWidget#0","result":{}}

断点发现异常机型setMessageHandler回调没有触发:
截屏2023-05-05 19 14 43