Skip to content

change(android): make FabricUIManager#resolveView not thread specific#54259

Open
hannojg wants to merge 1 commit into
react:mainfrom
hannojg:proposal/resolveView-concurrentaccess-safe
Open

change(android): make FabricUIManager#resolveView not thread specific#54259
hannojg wants to merge 1 commit into
react:mainfrom
hannojg:proposal/resolveView-concurrentaccess-safe

Conversation

@hannojg

@hannojg hannojg commented Oct 24, 2025

Copy link
Copy Markdown
Contributor

Summary:

FabricUIManager#resolveView is not using any thread specific annotation, but has a UiThreadUtil.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 ConcurrentHashMaps and thus FabricUIManager#resolveView is 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#resolveView not thread specific

Test Plan:

  • Run the example app and make sure everything still works
  • We tested this change and calling this method from another thread and it works without any weirdnesses

@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 Oct 24, 2025
@facebook-github-bot facebook-github-bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Oct 24, 2025
hannojg added a commit to discord/react-native that referenced this pull request Dec 11, 2025
@react-native-bot

Copy link
Copy Markdown
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.

@react-native-bot react-native-bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 23, 2026
@hannojg

hannojg commented Apr 29, 2026

Copy link
Copy Markdown
Contributor Author

still interested in this

@react-native-bot react-native-bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Apr 30, 2026
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. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants