RCTUnsafeExecuteOnMainQueueSync crash
Personne n'a encore pris cette issue.
- Langage dominant
- C++
- Étoiles
- 127k
- Forks
- 25.3k
- Merge moyen
- 1 j 23 h
- PR mergées (30 j)
- 4
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par le RNMainQueueCrashDemo lié et suivez l’initialisation de RCTRootView via RCTUnsafeExecuteOnMainQueueSync. Reproduisez le scénario UICollectionViewCell.init lors de l’application de la diffable data source et comparez-le à la stack trace signalée. La tâche est terminée lorsque le crash ne se produit plus dans ce chemin d’initialisation.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- ios, react
- Domaine
- mobile
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 25/100