Skip to content

Commit

Permalink
Fabric: Gating for new state reconciliation
Browse files Browse the repository at this point in the history
Summary:
The change is gated by two QEs (iOS and Android).

Changelog: [Internal] Fabric-specific internal change.

Reviewed By: mdvacca

Differential Revision: D21317797

fbshipit-source-id: 34bfd9546600d9cb3467bddfc61363a16683f81f
  • Loading branch information
shergin authored and facebook-github-bot committed Apr 30, 2020
1 parent afc3c97 commit f746119
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ReactCommon/fabric/mounting/ShadowTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ bool ShadowTree::tryCommit(
}

if (enableStateReconciliation) {
if (useNewApproachToStateReconciliation_) {
if (enableNewStateReconciliation_) {
auto updatedNewRootShadowNode =
progressState(*newRootShadowNode, *oldRootShadowNode);
if (updatedNewRootShadowNode) {
Expand Down
10 changes: 9 additions & 1 deletion ReactCommon/fabric/mounting/ShadowTree.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ class ShadowTree final {

MountingCoordinator::Shared getMountingCoordinator() const;

/*
* Temporary.
* Do not use.
*/
void setEnableNewStateReconciliation(bool value) {
enableNewStateReconciliation_ = value;
}

private:
RootShadowNode::Unshared cloneRootShadowNode(
RootShadowNode::Shared const &oldRootShadowNode,
Expand All @@ -88,7 +96,7 @@ class ShadowTree final {
mutable ShadowTreeRevision::Number revisionNumber_{
0}; // Protected by `commitMutex_`.
MountingCoordinator::Shared mountingCoordinator_;
bool useNewApproachToStateReconciliation_{true};
bool enableNewStateReconciliation_{false};
};

} // namespace react
Expand Down
10 changes: 10 additions & 0 deletions ReactCommon/fabric/scheduler/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ Scheduler::Scheduler(

delegate_ = delegate;
uiManager_ = uiManager;

#ifdef ANDROID
enableNewStateReconciliation_ = reactNativeConfig_->getBool(
"react_fabric:enable_new_state_reconciliation_android");
#else
enableNewStateReconciliation_ = reactNativeConfig_->getBool(
"react_fabric:enable_new_state_reconciliation_ios");
#endif
}

Scheduler::~Scheduler() {
Expand Down Expand Up @@ -141,6 +149,8 @@ void Scheduler::startSurface(
*rootComponentDescriptor_,
*uiManager_);

shadowTree->setEnableNewStateReconciliation(enableNewStateReconciliation_);

auto uiManager = uiManager_;

uiManager->getShadowTreeRegistry().add(std::move(shadowTree));
Expand Down
1 change: 1 addition & 0 deletions ReactCommon/fabric/scheduler/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class Scheduler final : public UIManagerDelegate {
std::shared_ptr<UIManager> uiManager_;
std::shared_ptr<const ReactNativeConfig> reactNativeConfig_;
EventDispatcher::Shared eventDispatcher_;
bool enableNewStateReconciliation_{false};
};

} // namespace react
Expand Down

0 comments on commit f746119

Please sign in to comment.