Summary:
The new C++ Differ has been validated on Android and iOS. Delete the old code path.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D28904330

fbshipit-source-id: 2e0d8682f6b2a79f9758ed8b7b92809060835815
This commit is contained in:
Joshua Gross 2021-06-07 17:10:45 -07:00 коммит произвёл Facebook GitHub Bot
Родитель 0823f299e5
Коммит 7d1d4dc064
18 изменённых файлов: 26 добавлений и 1689 удалений

Просмотреть файл

@ -124,7 +124,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
// Building an initial view hierarchy.
auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode);
viewTree.mutate(
calculateShadowViewMutations(*emptyRootNode, *currentRootNode, true));
calculateShadowViewMutations(*emptyRootNode, *currentRootNode));
for (int j = 0; j < stages; j++) {
auto nextRootNode = currentRootNode;
@ -151,7 +151,7 @@ static void testShadowNodeTreeLifeCycleLayoutAnimations(
// Calculating mutations.
auto originalMutations =
calculateShadowViewMutations(*currentRootNode, *nextRootNode, true);
calculateShadowViewMutations(*currentRootNode, *nextRootNode);
// If tree randomization produced no changes in the form of mutations,
// don't bother trying to animate because this violates a bunch of our

Просмотреть файл

@ -6,7 +6,6 @@
*/
#include "Differentiator.h"
#include "DifferentiatorFlatteningClassic.h"
#include <better/map.h>
#include <better/small_vector.h>
@ -1658,13 +1657,7 @@ ShadowViewNodePair::OwningList sliceChildShadowNodeViewPairsLegacy(
ShadowViewMutation::List calculateShadowViewMutations(
ShadowNode const &oldRootShadowNode,
ShadowNode const &newRootShadowNode,
bool useNewDiffer) {
if (!useNewDiffer) {
return DifferOld::calculateShadowViewMutations(
oldRootShadowNode, newRootShadowNode);
}
ShadowNode const &newRootShadowNode) {
SystraceSection s("calculateShadowViewMutations");
// Root shadow nodes must be belong the same family.

Просмотреть файл

@ -47,8 +47,7 @@ using ViewNodePairScope = std::deque<ShadowViewNodePair>;
*/
ShadowViewMutation::List calculateShadowViewMutations(
ShadowNode const &oldRootShadowNode,
ShadowNode const &newRootShadowNode,
bool useNewDiffer);
ShadowNode const &newRootShadowNode);
/**
* Generates a list of `ShadowViewNodePair`s that represents a layer of a

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,45 +0,0 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
// This file exists as an experimental baseline against which
// we can compare changes in Differentiator.
// Once changes in Differentiator have been verified safe,
// this file will be deleted.
#include <react/renderer/core/ShadowNode.h>
#include <react/renderer/debug/flags.h>
#include <react/renderer/mounting/ShadowViewMutation.h>
namespace facebook {
namespace react {
namespace DifferOld {
enum class ReparentMode { Flatten, Unflatten };
/*
* Calculates a list of view mutations which describes how the old
* `ShadowTree` can be transformed to the new one.
* The list of mutations might be and might not be optimal.
*/
ShadowViewMutationList calculateShadowViewMutations(
ShadowNode const &oldRootShadowNode,
ShadowNode const &newRootShadowNode);
/**
* Generates a list of `ShadowViewNodePair`s that represents a layer of a
* flattened view hierarchy. The V2 version preserves nodes even if they do
* not form views and their children are flattened.
*/
ShadowViewNodePairLegacy::OwningList sliceChildShadowNodeViewPairsV2(
ShadowNode const &shadowNode,
bool allowFlattened = false);
} // namespace DifferOld
} // namespace react
} // namespace facebook

Просмотреть файл

@ -90,9 +90,7 @@ better::optional<MountingTransaction> MountingCoordinator::pullTransaction()
telemetry.willDiff();
auto mutations = calculateShadowViewMutations(
*baseRevision_.rootShadowNode,
*lastRevision_->rootShadowNode,
enableNewDiffer_);
*baseRevision_.rootShadowNode, *lastRevision_->rootShadowNode);
telemetry.didDiff();
@ -188,9 +186,5 @@ void MountingCoordinator::setMountingOverrideDelegate(
mountingOverrideDelegate_ = delegate;
}
void MountingCoordinator::setEnableNewDiffer(bool enabled) const {
enableNewDiffer_ = enabled;
}
} // namespace react
} // namespace facebook

Просмотреть файл

@ -71,8 +71,6 @@ class MountingCoordinator final {
TelemetryController const &getTelemetryController() const;
void setEnableNewDiffer(bool enabled) const;
/*
* Methods from this section are meant to be used by
* `MountingOverrideDelegate` only.
@ -114,8 +112,6 @@ class MountingCoordinator final {
TelemetryController telemetryController_;
mutable bool enableNewDiffer_{false};
#ifdef RN_SHADOW_TREE_INTROSPECTION
mutable StubViewTree stubViewTree_; // Protected by `mutex_`.
#endif

Просмотреть файл

@ -223,8 +223,7 @@ ShadowTree::ShadowTree(
SurfaceId surfaceId,
LayoutConstraints const &layoutConstraints,
LayoutContext const &layoutContext,
ShadowTreeDelegate const &delegate,
bool enableNewDiffer)
ShadowTreeDelegate const &delegate)
: surfaceId_(surfaceId), delegate_(delegate) {
const auto noopEventEmitter = std::make_shared<const ViewEventEmitter>(
nullptr, -1, std::shared_ptr<const EventDispatcher>());
@ -253,7 +252,6 @@ ShadowTree::ShadowTree(
mountingCoordinator_ =
std::make_shared<MountingCoordinator const>(currentRevision_);
mountingCoordinator_->setEnableNewDiffer(enableNewDiffer);
}
ShadowTree::~ShadowTree() {

Просмотреть файл

@ -70,8 +70,7 @@ class ShadowTree final {
SurfaceId surfaceId,
LayoutConstraints const &layoutConstraints,
LayoutContext const &layoutContext,
ShadowTreeDelegate const &delegate,
bool enableNewDiffer);
ShadowTreeDelegate const &delegate);
~ShadowTree();

Просмотреть файл

@ -89,7 +89,7 @@ StubViewTree buildStubViewTreeUsingDifferentiator(
ShadowNode::emptySharedShadowNodeSharedList()});
auto mutations =
calculateShadowViewMutations(*emptyRootShadowNode, rootShadowNode, true);
calculateShadowViewMutations(*emptyRootShadowNode, rootShadowNode);
auto stubViewTree = StubViewTree(ShadowView(*emptyRootShadowNode));
stubViewTree.mutate(mutations);

Просмотреть файл

@ -242,8 +242,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
}*/
// Calculating mutations.
auto mutations1 =
calculateShadowViewMutations(*rootNodeV1, *rootNodeV2, true);
auto mutations1 = calculateShadowViewMutations(*rootNodeV1, *rootNodeV2);
// The order and exact mutation instructions here may change at any time.
// This test just ensures that any changes are intentional.
@ -259,8 +258,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
EXPECT_TRUE(mutations1[1].index == 0);
// Calculating mutations.
auto mutations2 =
calculateShadowViewMutations(*rootNodeV2, *rootNodeV3, true);
auto mutations2 = calculateShadowViewMutations(*rootNodeV2, *rootNodeV3);
// The order and exact mutation instructions here may change at any time.
// This test just ensures that any changes are intentional.
@ -276,8 +274,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
EXPECT_TRUE(mutations2[1].oldChildShadowView.tag == 100);
// Calculating mutations.
auto mutations3 =
calculateShadowViewMutations(*rootNodeV3, *rootNodeV4, true);
auto mutations3 = calculateShadowViewMutations(*rootNodeV3, *rootNodeV4);
LOG(ERROR) << "Num mutations IN OLD TEST mutations3: " << mutations3.size();
// The order and exact mutation instructions here may change at any time.
@ -299,8 +296,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
EXPECT_TRUE(mutations3[3].index == 2);
// Calculating mutations.
auto mutations4 =
calculateShadowViewMutations(*rootNodeV4, *rootNodeV5, true);
auto mutations4 = calculateShadowViewMutations(*rootNodeV4, *rootNodeV5);
// The order and exact mutation instructions here may change at any time.
// This test just ensures that any changes are intentional.
@ -325,8 +321,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
EXPECT_TRUE(mutations4[5].newChildShadowView.tag == 102);
EXPECT_TRUE(mutations4[5].index == 3);
auto mutations5 =
calculateShadowViewMutations(*rootNodeV5, *rootNodeV6, true);
auto mutations5 = calculateShadowViewMutations(*rootNodeV5, *rootNodeV6);
// The order and exact mutation instructions here may change at any time.
// This test just ensures that any changes are intentional.
@ -345,8 +340,7 @@ TEST(MountingTest, testReorderingInstructionGeneration) {
EXPECT_TRUE(mutations5[3].newChildShadowView.tag == 105);
EXPECT_TRUE(mutations5[3].index == 3);
auto mutations6 =
calculateShadowViewMutations(*rootNodeV6, *rootNodeV7, true);
auto mutations6 = calculateShadowViewMutations(*rootNodeV6, *rootNodeV7);
// The order and exact mutation instructions here may change at any time.
// This test just ensures that any changes are intentional.
@ -600,8 +594,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
rootNodeV5->sealRecursive();
// Calculating mutations.
auto mutations1 =
calculateShadowViewMutations(*rootNodeV1, *rootNodeV2, true);
auto mutations1 = calculateShadowViewMutations(*rootNodeV1, *rootNodeV2);
EXPECT_EQ(mutations1.size(), 5);
EXPECT_EQ(mutations1[0].type, ShadowViewMutation::Update);
@ -615,8 +608,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
EXPECT_EQ(mutations1[4].type, ShadowViewMutation::Insert);
EXPECT_EQ(mutations1[4].newChildShadowView.tag, 1000);
auto mutations2 =
calculateShadowViewMutations(*rootNodeV2, *rootNodeV3, true);
auto mutations2 = calculateShadowViewMutations(*rootNodeV2, *rootNodeV3);
EXPECT_EQ(mutations2.size(), 5);
EXPECT_EQ(mutations2[0].type, ShadowViewMutation::Update);
@ -632,8 +624,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
EXPECT_EQ(mutations2[4].type, ShadowViewMutation::Insert);
EXPECT_EQ(mutations2[4].newChildShadowView.tag, 1000);
auto mutations3 =
calculateShadowViewMutations(*rootNodeV3, *rootNodeV4, true);
auto mutations3 = calculateShadowViewMutations(*rootNodeV3, *rootNodeV4);
// between these two trees, lots of new nodes are created and inserted - this
// is all correct, and this is the minimal amount of mutations
@ -670,8 +661,7 @@ TEST(MountingTest, testViewReparentingInstructionGeneration) {
EXPECT_EQ(mutations3[14].type, ShadowViewMutation::Insert);
EXPECT_EQ(mutations3[14].newChildShadowView.tag, 1000);
auto mutations4 =
calculateShadowViewMutations(*rootNodeV4, *rootNodeV5, true);
auto mutations4 = calculateShadowViewMutations(*rootNodeV4, *rootNodeV5);
EXPECT_EQ(mutations4.size(), 9);
EXPECT_EQ(mutations4[0].type, ShadowViewMutation::Update);

Просмотреть файл

@ -79,7 +79,7 @@ static void testShadowNodeTreeLifeCycle(
// Building an initial view hierarchy.
auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode);
viewTree.mutate(
calculateShadowViewMutations(*emptyRootNode, *currentRootNode, true));
calculateShadowViewMutations(*emptyRootNode, *currentRootNode));
for (int j = 0; j < stages; j++) {
auto nextRootNode = currentRootNode;
@ -106,7 +106,7 @@ static void testShadowNodeTreeLifeCycle(
// Calculating mutations.
auto mutations =
calculateShadowViewMutations(*currentRootNode, *nextRootNode, true);
calculateShadowViewMutations(*currentRootNode, *nextRootNode);
// Make sure that in a single frame, a DELETE for a
// view is not followed by a CREATE for the same view.
@ -226,7 +226,7 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening(
// Building an initial view hierarchy.
auto viewTree = buildStubViewTreeWithoutUsingDifferentiator(*emptyRootNode);
viewTree.mutate(
calculateShadowViewMutations(*emptyRootNode, *currentRootNode, true));
calculateShadowViewMutations(*emptyRootNode, *currentRootNode));
for (int j = 0; j < stages; j++) {
auto nextRootNode = currentRootNode;
@ -254,7 +254,7 @@ static void testShadowNodeTreeLifeCycleExtensiveFlatteningUnflattening(
// Calculating mutations.
auto mutations =
calculateShadowViewMutations(*currentRootNode, *nextRootNode, true);
calculateShadowViewMutations(*currentRootNode, *nextRootNode);
// Make sure that in a single frame, a DELETE for a
// view is not followed by a CREATE for the same view.

Просмотреть файл

@ -171,8 +171,8 @@ class StackingContextTest : public ::testing::Test {
callback(buildStubViewTreeUsingDifferentiator(*rootShadowNode_));
callback(buildStubViewTreeWithoutUsingDifferentiator(*rootShadowNode_));
auto mutations = calculateShadowViewMutations(
*currentRootShadowNode_, *rootShadowNode_, true);
auto mutations =
calculateShadowViewMutations(*currentRootShadowNode_, *rootShadowNode_);
currentRootShadowNode_ = rootShadowNode_;
currentStubViewTree_.mutate(mutations);
callback(currentStubViewTree_);

Просмотреть файл

@ -98,11 +98,7 @@ TEST(StateReconciliationTest, testStateReconciliation) {
auto state1 = shadowNodeAB->getState();
auto shadowTreeDelegate = DummyShadowTreeDelegate{};
ShadowTree shadowTree{
SurfaceId{11},
LayoutConstraints{},
LayoutContext{},
shadowTreeDelegate,
true};
SurfaceId{11}, LayoutConstraints{}, LayoutContext{}, shadowTreeDelegate};
shadowTree.commit(
[&](RootShadowNode const &oldRootShadowNode) {

Просмотреть файл

@ -143,14 +143,11 @@ Scheduler::Scheduler(
#ifdef ANDROID
removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool(
"react_fabric:remove_outstanding_surfaces_on_destruction_android");
enableNewDiffer_ = reactNativeConfig_->getBool(
"react_fabric:enable_new_differ_h1_2021_android");
Constants::setPropsForwardingEnabled(reactNativeConfig_->getBool(
"react_fabric:enable_props_forwarding_android"));
#else
removeOutstandingSurfacesOnDestruction_ = reactNativeConfig_->getBool(
"react_fabric:remove_outstanding_surfaces_on_destruction_ios");
enableNewDiffer_ = true;
#endif
}
@ -213,7 +210,6 @@ Scheduler::~Scheduler() {
void Scheduler::registerSurface(
SurfaceHandler const &surfaceHandler) const noexcept {
surfaceHandler.setUIManager(uiManager_.get());
surfaceHandler.setEnableNewDiffer(enableNewDiffer_);
}
void Scheduler::unregisterSurface(

Просмотреть файл

@ -121,7 +121,6 @@ class Scheduler final : public UIManagerDelegate {
* Temporary flags.
*/
bool removeOutstandingSurfacesOnDestruction_{false};
bool enableNewDiffer_{false};
};
} // namespace react

Просмотреть файл

@ -71,8 +71,7 @@ void SurfaceHandler::start() const noexcept {
parameters.surfaceId,
parameters.layoutConstraints,
parameters.layoutContext,
*link_.uiManager,
enableNewDiffer_);
*link_.uiManager);
link_.shadowTree = shadowTree.get();
@ -139,11 +138,6 @@ DisplayMode SurfaceHandler::getDisplayMode() const noexcept {
return parameters_.displayMode;
}
#pragma mark - Feature Flags
void SurfaceHandler::setEnableNewDiffer(bool enabled) const noexcept {
enableNewDiffer_ = enabled;
}
#pragma mark - Accessors
SurfaceId SurfaceHandler::getSurfaceId() const noexcept {

Просмотреть файл

@ -138,9 +138,6 @@ class SurfaceHandler final {
LayoutConstraints getLayoutConstraints() const noexcept;
LayoutContext getLayoutContext() const noexcept;
#pragma mark - Feature Flags
void setEnableNewDiffer(bool enabled) const noexcept;
private:
friend class Scheduler;
@ -198,11 +195,6 @@ class SurfaceHandler final {
*/
mutable better::shared_mutex parametersMutex_;
mutable Parameters parameters_;
/**
* Feature flags.
*/
mutable bool enableNewDiffer_{false};
};
} // namespace react