RCTUnsafeExecuteOnMainQueueSync crash
オープン
まだ誰も着手していません。
Issue: Author Provided Repro
- 主要言語
- C++
- スター
- 127k
- フォーク
- 25.3k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 4
説明
Description
UIKit's UIView only guarantee to run on main thread/MainActor.
But ReactNative's RCTRootView is expecting to run on main queue.
This will cause crash when using RCTRootView in UICollectionViewCell which may call init on com.apple.uikit.datasource.diffing (serial) queue.
Steps to reproduce
Init a RCTRootView in a UICollectionViewCell.init method
React Native Version
0.76.2
Affected Platforms
Runtime - iOS
Output of npx react-native info
System:
OS: macOS 15.1
CPU: (10) arm64 Apple M2 Pro
Memory: 193.73 MB / 16.00 GB
Shell:
version: "5.9"
path: /bin/zsh
Binaries:
Node:
version: 23.2.0
path: /opt/homebrew/bin/node
Yarn:
version: 1.22.22
path: /opt/homebrew/bin/yarn
npm:
version: 10.9.0
path: /opt/homebrew/bin/npm
Watchman:
version: 2024.11.11.00
path: /opt/homebrew/bin/watchman
Managers:
CocoaPods:
version: 1.15.2
path: /Users/kyle/.rbenv/shims/pod
SDKs:
iOS SDK:
Platforms:
- DriverKit 24.0
- iOS 18.0
- macOS 15.0
- tvOS 18.0
- visionOS 2.0
- watchOS 11.0
Android SDK: Not Found
IDEs:
Android Studio: Not Found
Xcode:
version: 16.0/16A242d
path: /usr/bin/xcodebuild
Languages:
Java: Not Found
Ruby:
version: 3.3.0
path: /Users/kyle/.rbenv/shims/ruby
npmPackages:
"@react-native-community/cli":
installed: 15.0.1
wanted: 15.0.1
react:
installed: 18.3.1
wanted: 18.3.1
react-native:
installed: 0.76.2
wanted: 0.76.2
react-native-macos: Not Found
npmGlobalPackages:
"*react-native*": Not Found
Android:
hermesEnabled: true
newArchEnabled: true
iOS:
hermesEnabled: true
newArchEnabled: true
Stacktrace or Logs
- dataSource.apply(_:to:animatingDifferences:) (in main queue & MainThread)
- __UIDiffableDataSource _performOnApplyQueue: use dispatch_sync(diffQueue)
- ...
- RCTRootView init (in diffQueue & MainThread)
- RCTUnsafeExecuteOnMainQueueSync (crash)
Reproducer
https://github.com/Kyle-Ye/RNMainQueueCrashDemo
Screenshots and Videos
Other information
The original discussion can be found at here
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
リンクされている RNMainQueueCrashDemo から始め、RCTUnsafeExecuteOnMainQueueSync を経由する RCTRootView の初期化を追跡します。diffable data source の適用中に UICollectionViewCell.init のシナリオを再現し、報告された stack trace と比較します。この初期化パスでクラッシュが発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- ios, react
- 領域
- mobile
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 25/100