From 5b37072484de4d10646840a6dc70d96e5f5a5f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Mon, 14 Oct 2024 02:17:27 -0700 Subject: [PATCH] Fix race condition when reporting mounting transactions for deallocated surfaces Summary: Changelog: [internal] This code is gated anyway so there's no harm in production. Differential Revision: D64322331 --- .../react/defaults/DefaultNewArchitectureEntryPoint.kt | 1 - .../ReactNativeNewArchitectureFeatureFlagsDefaults.kt | 7 ++----- .../src/main/jni/react/fabric/FabricUIManagerBinding.cpp | 5 ++++- 3 files changed, 6 insertions(+), 7 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/{internal/featureflags => defaults}/ReactNativeNewArchitectureFeatureFlagsDefaults.kt (83%) diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt index f90ad0246a36f9..8cc0f429b14c4e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultNewArchitectureEntryPoint.kt @@ -11,7 +11,6 @@ package com.facebook.react.defaults import com.facebook.react.common.annotations.VisibleForTesting import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags -import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlagsDefaults /** * A utility class that serves as an entry point for users setup the New Architecture. diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeNewArchitectureFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/ReactNativeNewArchitectureFeatureFlagsDefaults.kt similarity index 83% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeNewArchitectureFeatureFlagsDefaults.kt rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/ReactNativeNewArchitectureFeatureFlagsDefaults.kt index 985dd7e0777a4f..eb30b1c57a2eef 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeNewArchitectureFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/ReactNativeNewArchitectureFeatureFlagsDefaults.kt @@ -5,18 +5,15 @@ * LICENSE file in the root directory of this source tree. */ -@file:Suppress("DEPRECATION") // We want to use ReactFeatureFlags here specifically +package com.facebook.react.defaults -package com.facebook.react.internal.featureflags +import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsDefaults /** * This class initializes default values for ReactNativeFeatureFlags when the New architecture is * enabled. This class is meant to be overrode only by internal apps migrating to the new * architecture. * - * NOTE: Be aware that as a side effect this class also modifies static fields in {@link - * com.facebook.react.config.ReactFeatureFlags} when newArchitectureEnabled is true. - * * When the new architecture is enabled, we want to set the default values of the flags for Fabric, * TurboModules and Bridgeless as enabled by default. */ diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp index 2e2e50f315c3ad..76384785d33d2e 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/fabric/FabricUIManagerBinding.cpp @@ -121,7 +121,10 @@ void FabricUIManagerBinding::reportMount(SurfaceId surfaceId) { } } if (surfaceHandler != nullptr) { - surfaceHandler->getMountingCoordinator()->didPerformAsyncTransactions(); + auto mountingCoordinator = surfaceHandler->getMountingCoordinator(); + if (mountingCoordinator != nullptr) { + mountingCoordinator->didPerformAsyncTransactions(); + } } } else { LOG(ERROR) << "FabricUIManagerBinding::reportMount: Surface with id "