diff --git a/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm b/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm index 086849f2be4951..0e7cc3f383cf69 100644 --- a/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm +++ b/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm @@ -17,6 +17,7 @@ #import #import #import +#import #import #import #import @@ -49,8 +50,10 @@ static void RCTPerformMountInstructions( { SystraceSection s("RCTPerformMountInstructions"); - [CATransaction begin]; - [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + if (!CoreFeatures::disableTransactionCommit) { + [CATransaction begin]; + [CATransaction setValue:(id)kCFBooleanTrue forKey:kCATransactionDisableActions]; + } for (auto const &mutation : mutations) { switch (mutation.type) { case ShadowViewMutation::Create: { @@ -149,7 +152,9 @@ static void RCTPerformMountInstructions( } } } - [CATransaction commit]; + if (!CoreFeatures::disableTransactionCommit) { + [CATransaction commit]; + } } @implementation RCTMountingManager { diff --git a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm index e7aa631d49f296..7b09c995700cca 100644 --- a/packages/react-native/React/Fabric/RCTSurfacePresenter.mm +++ b/packages/react-native/React/Fabric/RCTSurfacePresenter.mm @@ -272,6 +272,10 @@ - (RCTScheduler *)_createScheduler CoreFeatures::cancelImageDownloadsOnRecycle = true; } + if (reactNativeConfig && reactNativeConfig->getBool("react_fabric:disable_transaction_commit")) { + CoreFeatures::disableTransactionCommit = true; + } + auto componentRegistryFactory = [factory = wrapManagedObject(_mountingManager.componentViewRegistry.componentViewFactory)]( EventDispatcher::Weak const &eventDispatcher, ContextContainer::Shared const &contextContainer) { diff --git a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.cpp b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.cpp index 937e40aa0bf5ae..351a257d67877e 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.cpp +++ b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.cpp @@ -15,5 +15,6 @@ bool CoreFeatures::blockPaintForUseLayoutEffect = false; bool CoreFeatures::useNativeState = false; bool CoreFeatures::cacheLastTextMeasurement = false; bool CoreFeatures::cancelImageDownloadsOnRecycle = false; +bool CoreFeatures::disableTransactionCommit = false; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h index 5c49928e226513..f9a07875d270f2 100644 --- a/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h +++ b/packages/react-native/ReactCommon/react/renderer/core/CoreFeatures.h @@ -43,6 +43,11 @@ class CoreFeatures { // Fabric was not cancelling image downloads when was removed // from view hierarchy. This feature flag enables this feature. static bool cancelImageDownloadsOnRecycle; + + // On iOS, every transaction is wrapperd in [CATransaction begin] and + // [CATransaction end] This feature flag disables it to measure its impact in + // production. + static bool disableTransactionCommit; }; } // namespace facebook::react