Skip to content

Conversation

christophpurrer
Copy link
Contributor

Summary:
Changelog: [Internal]

The issue is a race condition in the React Native Fabric mounting system where experimental_prefetchResources is called on a SurfaceMountingManager after the surface has been stopped.

1.) experimental_prefetchResources is called
2.) Concurrently, stopSurface() can be called, which sets mThemedReactContext = null
3.) experimental_prefetchResources then tries to access mThemedReactContext via Assertions.assertNotNull(mThemedReactContext)
4.) Since mThemedReactContext is now null, the assertion fails and throws an AssertionError

The fix involves adding a guard to check if the surface is stopped before accessing mThemedReactContext

Follows existing patterns used by other methods in the same class

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L201-L213

Differential Revision: D82842572

… stop

Summary:
Changelog: [Internal]

The issue is a race condition in the React Native Fabric mounting system where `experimental_prefetchResources` is called on a `SurfaceMountingManager` after the surface has been stopped.


1.) `experimental_prefetchResources` is called
2.) Concurrently, `stopSurface()` *can be* called, which sets `mThemedReactContext = null`
3.) `experimental_prefetchResources` then tries to access `mThemedReactContext` via `Assertions.assertNotNull(mThemedReactContext)`
4.) Since `mThemedReactContext` is now `null`, the assertion fails and throws an AssertionError

The fix involves adding a guard to check if the surface is stopped before accessing `mThemedReactContext`

Follows existing patterns used by other methods in the same class

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L201-L213

Differential Revision: D82842572
@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 Sep 19, 2025
@facebook-github-bot
Copy link
Contributor

@christophpurrer has exported this pull request. If you are a Meta employee, you can view the originating diff in D82842572.

christophpurrer added a commit to christophpurrer/react-native-macos that referenced this pull request Sep 19, 2025
… stop (facebook#53861)

Summary:

Changelog: [Internal]

The issue is a race condition in the React Native Fabric mounting system where `experimental_prefetchResources` is called on a `SurfaceMountingManager` after the surface has been stopped.


1.) `experimental_prefetchResources` is called
2.) Concurrently, `stopSurface()` *can be* called, which sets `mThemedReactContext = null`
3.) `experimental_prefetchResources` then tries to access `mThemedReactContext` via `Assertions.assertNotNull(mThemedReactContext)`
4.) Since `mThemedReactContext` is now `null`, the assertion fails and throws an AssertionError

The fix involves adding a guard to check if the surface is stopped before accessing `mThemedReactContext`

Follows existing patterns used by other methods in the same class

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L201-L213

Reviewed By: lenaic

Differential Revision: D82842572
christophpurrer added a commit to christophpurrer/react-native-macos that referenced this pull request Sep 20, 2025
… stop (facebook#53861)

Summary:

Changelog: [Internal]

The issue is a race condition in the React Native Fabric mounting system where `experimental_prefetchResources` is called on a `SurfaceMountingManager` after the surface has been stopped.


1.) `experimental_prefetchResources` is called
2.) Concurrently, `stopSurface()` *can be* called, which sets `mThemedReactContext = null`
3.) `experimental_prefetchResources` then tries to access `mThemedReactContext` via `Assertions.assertNotNull(mThemedReactContext)`
4.) Since `mThemedReactContext` is now `null`, the assertion fails and throws an AssertionError

The fix involves adding a guard to check if the surface is stopped before accessing `mThemedReactContext`

Follows existing patterns used by other methods in the same class

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java#L201-L213

Reviewed By: lenaic

Differential Revision: D82842572
@facebook-github-bot facebook-github-bot added the Merged This PR has been merged. label Sep 20, 2025
@facebook-github-bot
Copy link
Contributor

This pull request has been merged in 362ed17.

@react-native-bot
Copy link
Collaborator

This pull request was successfully merged by @christophpurrer in 362ed17

When will my fix make it into a release? | How to file a pick request?

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. fb-exported Merged This PR has been merged. meta-exported p: Facebook Partner: Facebook Partner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants