Runtime Exceptions in TurboModule Void Methods Crash the App
还没有人认领这个 Issue。
- 主要语言
- C++
- 星标
- 127k
- 派生
- 25.3k
- 平均合并
- 1 天 23 小时
- 30 天内合并 PR
- 4
描述
Description
When raising a runtime exception (RuntimeException on Android, NSException on iOS) in a TurboModule the behavior is different based on whether the method in the TurboModule has a return type or is declared as void.
If the method that raises the exception has a return type, the exception is visible in the Javascript code that called the method. The error can be handled in a catch statement and if it's not then the standard error screen is shown in development.
If the method that raises the exception is declared as void, the behavior is slightly different between iOS and Android. On iOS, the app immediately crashes (if a debugger is attached, the cause is often EXC_BAD_ACCESS). On Android, the standard error screen is shown but then the app stops responding (the UI goes white and the app is frozen).
This reproducer project has a TurboModule with two methods: nonVoidFunction and voidFunction. Each is implemented to raise a runtime exception. There are two buttons on the main screen, one to call each function. Tapping the "Non Void Function" button calls the corresponding function and the standard error screen is displayed. After dismissing or minimizing the error, the app continues to function. Tapping the "Void Function" button exhibits the behavior described above (white screen on Android, crash on iOS).
Steps to reproduce
- Clone the reproducer project
- Run the application and tap the "Void Function" button
React Native Version
0.81.4
Affected Platforms
Runtime - Android, Runtime - iOS
Areas
TurboModule - The New Native Module System
Output of npx @react-native-community/cli info
System:
OS: macOS 15.7
CPU: (12) arm64 Apple M4 Pro
Memory: 125.47 MB / 24.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 22.14.0
path: ~/.nvm/versions/node/v22.14.0/bin/node
Yarn:
version: 1.22.22
path: ~/.nvm/versions/node/v22.14.0/bin/yarn
npm:
version: 10.9.2
path: ~/.nvm/versions/node/v22.14.0/bin/npm
Watchman:
version: 2024.12.02.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods: Not Found
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.5
- iOS 18.5
- macOS 15.5
- tvOS 18.5
- visionOS 2.5
- watchOS 11.5
Android SDK: Not Found
IDEs:
Android Studio: 2025.1 AI-251.25410.109.2511.13752376
Xcode:
version: 16.4/16F6
path: /usr/bin/xcodebuild
Languages:
Java:
version: 17.0.14
path: /usr/bin/javac
Ruby:
version: 2.7.2
path: /Users/sean/.asdf/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 20.0.0
wanted: 20.0.0
react:
installed: 19.1.0
wanted: 19.1.0
react-native:
installed: 0.81.4
wanted: 0.81.4
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
Not available. See description and reproduction steps above.
MANDATORY Reproducer
https://github.com/picassomd/turbo-modules-exceptions
Screenshots and Videos
No response
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从必需的复现项目开始,并比较 Android 和 iOS 上名为 nonVoidFunction 和 voidFunction 的 TurboModule 方法。跟踪 void 方法产生的运行时异常与具有返回类型的方法产生的异常分别如何处理。完成标准是:void 方法的异常能够一致地传递到 JavaScript,同时不会导致 Android 卡死或 iOS 崩溃。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- android, ios, react-native
- 领域
- mobile-dev
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 42/100