change(android): make FabricUIManager#resolveView not thread specific#54259
Open
hannojg wants to merge 1 commit into
Open
change(android): make FabricUIManager#resolveView not thread specific#54259hannojg wants to merge 1 commit into
FabricUIManager#resolveView not thread specific#54259hannojg wants to merge 1 commit into
Conversation
hannojg
added a commit
to discord/react-native
that referenced
this pull request
Dec 11, 2025
Collaborator
|
This PR is stale because it has been open for 180 days with no activity. It will be closed in 7 days unless you comment on it or remove the "Stale" label. |
Contributor
Author
|
still interested in this |
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.
Summary:
FabricUIManager#resolveViewis not using any thread specific annotation, but has aUiThreadUtil.assertOnUiThread()check:https://github.com/facebook/react-native/blob/d9262c60f4c02d66417008970dc9c34b742aaa75/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java#L1034-L1037
However, after checking all data structures used, it appears that all of them are
ConcurrentHashMapsand thusFabricUIManager#resolveViewis actually thread safe:https://github.com/facebook/react-native/blob/d93d32547bfadba731999ea251ca5e1d6c6c8912/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java#L1038
https://github.com/facebook/react-native/blob/d93d32547bfadba731999ea251ca5e1d6c6c8912/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L81
https://github.com/facebook/react-native/blob/d93d32547bfadba731999ea251ca5e1d6c6c8912/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/MountingManager.kt#L43
I am proposing to remove the
UiThreadUtil.assertOnUiThread()check here.Motivation:
From another thread we want to check if a certain react tag is already mounted in the native view hierarchy. It should be the callers responsibility to make sure to only operate on that view from the UI thread.
Changelog:
[ANDROID] [CHANGED] Make
FabricUIManager#resolveViewnot thread specificTest Plan: