Skip to content

Commit

Permalink
Fabric: Controlling DifferentiatorMode via ReactNativeConfig
Browse files Browse the repository at this point in the history
Summary:
Now we can control the differentiator mode via MC.

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: fkgozali

Differential Revision: D20978857

fbshipit-source-id: 13264948762f02f874d8d051c873d378062d6db4
  • Loading branch information
shergin authored and facebook-github-bot committed Apr 11, 2020
1 parent be78673 commit d7d585f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions React/Fabric/Mounting/RCTMountingManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, weak) id<RCTMountingManagerDelegate> delegate;
@property (nonatomic, strong) RCTComponentViewRegistry *componentViewRegistry;

@property (atomic, assign) BOOL useModernDifferentiatorMode;

/**
* Schedule a mounting transaction to be performed on the main thread.
* Can be called from any thread.
Expand Down
5 changes: 4 additions & 1 deletion React/Fabric/Mounting/RCTMountingManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,10 @@ - (void)performTransaction:(MountingCoordinator::Shared const &)mountingCoordina
SystraceSection s("-[RCTMountingManager performTransaction:]");
RCTAssertMainQueue();

auto transaction = mountingCoordinator->pullTransaction(DifferentiatorMode::Classic);
auto differentiatorMode =
self.useModernDifferentiatorMode ? DifferentiatorMode::OptimizedMoves : DifferentiatorMode::Classic;

auto transaction = mountingCoordinator->pullTransaction(differentiatorMode);
if (!transaction.has_value()) {
return;
}
Expand Down
7 changes: 7 additions & 0 deletions React/Fabric/RCTSurfacePresenter.mm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#import <React/RCTUtils.h>

#import <react/components/root/RootShadowNode.h>
#import <react/config/ReactNativeConfig.h>
#import <react/core/LayoutConstraints.h>
#import <react/core/LayoutContext.h>
#import <react/uimanager/ComponentDescriptorFactory.h>
Expand Down Expand Up @@ -299,6 +300,12 @@ - (RCTScheduler *)_createScheduler
RCTScheduler *scheduler = [[RCTScheduler alloc] initWithToolbox:toolbox];
scheduler.delegate = self;

auto reactNativeConfig = _contextContainer->at<std::shared_ptr<ReactNativeConfig const>>("ReactNativeConfig");
if (reactNativeConfig) {
_mountingManager.useModernDifferentiatorMode =
reactNativeConfig->getBool("react_fabric:enabled_optimized_moves_differ_ios");
}

return scheduler;
}

Expand Down

0 comments on commit d7d585f

Please sign in to comment.