Skip to content

Conversation

@hannojg
Copy link
Contributor

@hannojg hannojg commented Oct 24, 2025

Summary:

FabricUIManager#resolveView is not using any thread specific annotation, but has a UiThreadUtil.assertOnUiThread() check:

public @Nullable View resolveView(int reactTag) {
UiThreadUtil.assertOnUiThread();
SurfaceMountingManager surfaceManager = mMountingManager.getSurfaceManagerForView(reactTag);

However, after checking all data structures used, it appears that all of them are ConcurrentHashMaps and thus FabricUIManager#resolveView is actually thread safe:

return surfaceManager == null ? null : surfaceManager.getView(reactTag);

private val surfaceIdToManager = ConcurrentHashMap<Int, SurfaceMountingManager>() // any thread

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
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.

2 participants