Repository navigation
[temp] Video uploads for Modal PRs - #1
Closed
fairysword wants to merge 1 commit into
Closed
fairysword wants to merge 1 commit into
fairysword wants to merge 1 commit into
Conversation
fairysword
pushed a commit
that referenced
this pull request
Nov 27, 2026
…/Unimplemented fallbacks ## Summary: `-[RCTComponentViewFactory _registerComponentIfPossible:]` runs on the JS thread, from the `ComponentDescriptorProviderRegistry` request callback. Its legacy-interop fallback and its `UnimplementedView` fallback write `_componentViewClasses` and `_registrationStatusMap` **without taking `_mutex`**. Its early `_registrationStatusMap.find` and `-_wasComponentRegistered:` also read without the lock. On the main thread, `-createComponentViewWithComponentHandle:` takes only `std::shared_lock lock(_mutex)` before it calls `_componentViewClasses.find(handle)`. So an unlocked insert, particularly one that rehashes the map, can make that lookup miss a handle registered long ago. In practice the missed handle is often the built-in `Paragraph`: - Debug builds abort with `RCTAssert: ComponentView with componentHandle … (Paragraph) not found.` - Release builds compile the assert out and dereference the end iterator. react#58299 reports a production SIGSEGV at fault address `0x18`. Any app that renders a component through the legacy interop layer is exposed: a library without Fabric codegen, `RNCMaskedView`, or any host name that resolves to `UnimplementedView`. The first render of each such name is a writer. This PR takes the factory lock only around the map reads and writes: - `std::shared_lock` in `-_wasComponentRegistered:` and around the early status-map check. - In both fallbacks, the provider and class descriptor are built and `_providerRegistry.add(provider)` is called with no factory lock held. Then `std::unique_lock` is taken for the two map writes only. The ordering is safe. `_registerComponentIfPossible:` runs synchronously inside `ComponentDescriptorRegistry::at` on the JS thread, and returns only after the writes, so the new name cannot be used before the maps hold it. Upstream already adds the provider before writing the maps. The lock deliberately does **not** span `_providerRegistry.add`, unlike the fix proposed in react#58299. Building a `LegacyViewManagerInteropComponentDescriptor` can lazily load a view manager that requires main-queue setup (`RCTUnsafeExecuteOnMainQueueSync`; see react#53128). Holding the factory lock across that would deadlock against a main thread waiting for the lock in `-createComponentViewWithComponentHandle:`. With this change, nothing but map operations runs under the lock. Fixes react#60244 (re-files react#58299) (closed by the bot for lack of a reproducer; the race is still present on `main`). ## Changelog: [IOS] [FIXED] - Fix a data race in `RCTComponentViewFactory` where legacy-interop and Unimplemented component registration wrote the component registry without its lock, which could crash view creation ("ComponentView … (Paragraph) not found"). ## Test Plan: **ThreadSanitizer, before and after.** Setup: - React Native built from source for the iOS simulator, iOS 27.2 runtime, Xcode 27.2. - `-fsanitize=thread` added as a per-file compiler flag on `RCTComponentViewFactory.mm`, plus the link flag. - A dev-only stress screen in a bridgeless app: - mounts a batch of 1,500 `<Text>` on alternate frames, more than the 1,024-view recycle pool, so the main thread keeps creating views; - right after each batch commits, on the JS thread, creates detached shadow nodes under host names never seen before (`nativeFabricUIManager.createNode(tag, "Probe" + n, rootTag, {}, {})`). Each one forces an `UnimplementedView` fallback registration. **Without this change,** TSan reports: ``` WARNING: ThreadSanitizer: data race Read of size 8 by main thread: #0-#1 std::unordered_map<long long, RCTComponentViewClassDescriptor>::find react#2 -[RCTComponentViewFactory createComponentViewWithComponentHandle:] react#3 -[RCTComponentViewRegistry _dequeueComponentViewWithComponentHandle:] Previous write of size 8 by thread T15: #0-react#3 std::unordered_map<…RCTComponentViewClassDescriptor…> insert react#4 -[RCTComponentViewFactory _registerComponentIfPossible:] (UnimplementedView fallback) … ComponentDescriptorProviderRegistry request callback ``` **With this change,** the same build, harness and run report no data race. **Also run:** the app's full Jest suite and its iOS end-to-end flows on the patched source build. The stress harness drives only the `UnimplementedView` fallback, because fresh legacy view-manager names can't be minted at runtime. The legacy-interop fallback gets the same lock shape, and is covered by code reading rather than by a TSan run. Also unlocked but **not** changed here: `+[RCTLegacyViewManagerInteropComponentView isSupported:]` writes a static `NSMutableDictionary`. Its only caller is the legacy-interop fallback, on the JS thread. Differential Revision: D134467315 Pull Request resolved: react#60243
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Temporary PR used only to host video uploads for upstream pull requests. Will be closed.
api28-venus-both-bars-opaque.mp4
api28-venus-both-bars-opaque.mp4
api28-venus-status-bar-translucent.mp4
api28-venus-status-bar-translucent.mp4
api28-venus-both-bars-translucent.mp4
api28-venus-both-bars-translucent.mp4
api34-samsung-both-bars-opaque.mp4
api34-samsung-both-bars-opaque.mp4
api34-samsung-status-bar-translucent.mp4
api34-samsung-status-bar-translucent.mp4
api34-samsung-both-bars-translucent.mp4
api34-samsung-both-bars-translucent.mp4
api36-vivo-system-edge-to-edge.mp4
api36-vivo-system-edge-to-edge.mp4
api28-venus-both-bars-translucent-3way.mp4
api28-venus-both-bars-translucent-3way.mp4