Skip to content

Commit 1f0b27a

Browse files
rubennortefacebook-github-bot
authored andcommitted
Fix crash in fixMountingCoordinatorReportedPendingTransactionsOnAndroid feature flag (facebook#50088)
Summary: Pull Request resolved: facebook#50088 Changelog: [internal] This fixes a crash when using the `fixMountingCoordinatorReportedPendingTransactionsOnAndroid` feature flag. The problem was that we were accessing the surface handler registry safely, but there were cases where invalid surface handler references were being kept in the registry. Reviewed By: javache Differential Revision: D71387111 fbshipit-source-id: 643fcdf10c4c5751d77e276efb37795b7af726bb
1 parent ac97177 commit 1f0b27a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ void FabricUIManagerBinding::stopSurfaceWithSurfaceHandler(
318318
<< this << ", surfaceId: " << surfaceHandler.getSurfaceId() << ").";
319319
}
320320

321+
// This is necessary to make sure we remove the surface handler from the
322+
// registry before invalidating it. Otherwise, we can access an invalid
323+
// reference in `reportMount`.
324+
if (ReactNativeFeatureFlags::
325+
fixMountingCoordinatorReportedPendingTransactionsOnAndroid()) {
326+
std::unique_lock lock(surfaceHandlerRegistryMutex_);
327+
surfaceHandlerRegistry_.erase(surfaceHandler.getSurfaceId());
328+
}
329+
321330
surfaceHandler.stop();
322331

323332
auto scheduler = getScheduler();
@@ -328,7 +337,8 @@ void FabricUIManagerBinding::stopSurfaceWithSurfaceHandler(
328337
}
329338
scheduler->unregisterSurface(surfaceHandler);
330339

331-
{
340+
if (!ReactNativeFeatureFlags::
341+
fixMountingCoordinatorReportedPendingTransactionsOnAndroid()) {
332342
std::unique_lock lock(surfaceHandlerRegistryMutex_);
333343
surfaceHandlerRegistry_.erase(surfaceHandler.getSurfaceId());
334344
}

0 commit comments

Comments
 (0)