Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a feature flag to disable [CATransaction commit] during mount #37459

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#import <React/RCTUtils.h>
#import <react/config/ReactNativeConfig.h>
#import <react/renderer/components/root/RootShadowNode.h>
#import <react/renderer/core/CoreFeatures.h>
#import <react/renderer/core/LayoutableShadowNode.h>
#import <react/renderer/core/RawProps.h>
#import <react/renderer/debug/SystraceSection.h>
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -149,7 +152,9 @@ static void RCTPerformMountInstructions(
}
}
}
[CATransaction commit];
if (!CoreFeatures::disableTransactionCommit) {
[CATransaction commit];
}
}

@implementation RCTMountingManager {
Expand Down
4 changes: 4 additions & 0 deletions packages/react-native/React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ class CoreFeatures {
// Fabric was not cancelling image downloads when <ImageView /> 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