react / react/react-native

RCTUnsafeExecuteOnMainQueueSync crash

Offen
#47,645 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Issue: Author Provided Repro
Vorherrschende Sprache
C++
Sterne
127k
Forks
25.3k
Ø Merge
1 T. 23 Std.
Gemergte PRs (30 T.)
4

Beschreibung

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
image
Other information

The original discussion can be found at here

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit dem verlinkten RNMainQueueCrashDemo und verfolge die Initialisierung von RCTRootView über RCTUnsafeExecuteOnMainQueueSync. Reproduziere das UICollectionViewCell.init-Szenario während der Anwendung der diffable data source und vergleiche es mit dem gemeldeten Stack Trace. Erledigt ist die Aufgabe, wenn der Absturz in diesem Initialisierungspfad nicht mehr auftritt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
ios, react
Bereich
mobile
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.