Skip to content

[DO NOT MERGE] Reproducer for #60244: RCTComponentViewFactory registration race - #60246

Draft
adeelejaz wants to merge 1 commit into
react:mainfrom
adeelejaz:repro-component-view-factory-race
Draft

adeelejaz wants to merge 1 commit into
react:mainfrom
adeelejaz:repro-component-view-factory-race

Conversation

@adeelejaz

Copy link
Copy Markdown

Summary:

Reproducer for #60244 (a re-file of #58299), as the issue bot asks. Not for merge. It only edits RNTesterPlayground.js. The fix is in #60243.

The playground mounts a 1,500-Text batch on alternate frames, more than the 1,024-view recycle pool, so the main thread keeps creating views. Right after each batch commits, it creates detached shadow nodes under component names the factory has never seen (nativeFabricUIManager.createNode). Each one forces the UnimplementedView fallback in -[RCTComponentViewFactory _registerComponentIfPossible:], which writes the factory's maps without _mutex, while the main thread reads them in -createComponentViewWithComponentHandle:.

Changelog:

[INTERNAL] - Reproducer only; not for merge.

Test Plan:

  1. Build RNTester for an iOS simulator (New Architecture), with ThreadSanitizer enabled only on packages/react-native/React/Fabric/Mounting/RCTComponentViewFactory.mm: add -fsanitize=thread to that file's compiler flags, and -fsanitize=thread to the app's linker flags. Instrumenting the whole app also works, but is slow.
  2. Open Playground and press Start.
  3. Without the fix: within seconds, ThreadSanitizer reports a data race. The main-thread read is _componentViewClasses.find in -createComponentViewWithComponentHandle:. The other thread's write is in -_registerComponentIfPossible:, in the UnimplementedView fallback.
  4. With the fix ([iOS][Fabric] Fix data race in RCTComponentViewFactory legacy-interop/Unimplemented fallbacks #60243): no data race, and the run ends with "Done: no crash".

Without ThreadSanitizer the race is intermittent. A Debug build sometimes aborts with RCTAssert: ComponentView with componentHandle … (Paragraph) not found; a Release build may crash on the dereferenced end iterator (see #58299).

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant