Skip to content

Commit 362ed17

Browse files
Fix race condition between experimental_prefetchResources and surface stop (#53861)
Summary: Pull Request resolved: #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
1 parent fcbe4d1 commit 362ed17

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,9 @@ private void updateProps(
821821
@UnstableReactNativeAPI
822822
public void experimental_prefetchResources(
823823
int surfaceId, String componentName, MapBuffer params) {
824+
if (isStopped()) {
825+
return;
826+
}
824827
mViewManagerRegistry
825828
.get(componentName)
826829
.experimental_prefetchResources(

0 commit comments

Comments
 (0)