A framework for building native applications using React
Fix race condition between experimental_prefetchResources and surface stop (#53861)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53861 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 fbshipit-source-id: 723bad24a075efa219766b0e148080dd42d59fba
C
Christoph Purrer committed
362ed179a8eb5d2d764b53766b70a9e917017171
Parent: fcbe4d1
Committed by Facebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
on 9/20/2025, 12:27:14 AM