Skip to content
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 @@ -95,7 +95,7 @@ RootShadowNode::Unshared ReanimatedCommitHook::shadowTreeWillCommit(
PropsMap propsMap = updatesRegistryManager_->collectProps();
updatesRegistryManager_->cancelCommitAfterPause();

rootNode = cloneShadowTreeWithNewProps(*rootNode, propsMap);
rootNode = cloneShadowTreeWithNewProps(*rootNode, propsMap, commitOptions.source == ShadowTreeCommitSource::React);
// If the commit comes from React Native then pause commits from
// Reanimated since the ShadowTree to be committed by Reanimated may not
// include the new changes from React Native yet and all changes of animated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,30 @@ Props::Shared mergeProps(const ShadowNode &shadowNode, const PropsMap &propsMap,
std::shared_ptr<ShadowNode> cloneShadowTreeWithNewPropsRecursive(
const ShadowNode &shadowNode,
const ChildrenMap &childrenMap,
const PropsMap &propsMap) {
const PropsMap &propsMap,
bool enableRuntimeReferenceUpdates) {
const auto family = &shadowNode.getFamily();
const auto affectedChildrenIt = childrenMap.find(family);
auto children = shadowNode.getChildren();

if (affectedChildrenIt != childrenMap.end()) {
for (const auto index : affectedChildrenIt->second) {
children[index] = cloneShadowTreeWithNewPropsRecursive(*children[index], childrenMap, propsMap);
children[index] =
cloneShadowTreeWithNewPropsRecursive(*children[index], childrenMap, propsMap, enableRuntimeReferenceUpdates);
}
}

return shadowNode.clone(
{mergeProps(shadowNode, propsMap, *family),
std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(children),
shadowNode.getState(),
false});
enableRuntimeReferenceUpdates});
}

RootShadowNode::Unshared cloneShadowTreeWithNewProps(const RootShadowNode &oldRootNode, const PropsMap &propsMap) {
RootShadowNode::Unshared cloneShadowTreeWithNewProps(
const RootShadowNode &oldRootNode,
const PropsMap &propsMap,
bool enableRuntimeReferenceUpdates) {
ReanimatedSystraceSection s("ShadowTreeCloner::cloneShadowTreeWithNewProps");

ChildrenMap childrenMap;
Expand All @@ -85,7 +90,7 @@ RootShadowNode::Unshared cloneShadowTreeWithNewProps(const RootShadowNode &oldRo
// This cast is safe, because this function returns a clone
// of the oldRootNode, which is an instance of RootShadowNode
return std::static_pointer_cast<RootShadowNode>(
cloneShadowTreeWithNewPropsRecursive(oldRootNode, childrenMap, propsMap));
cloneShadowTreeWithNewPropsRecursive(oldRootNode, childrenMap, propsMap, enableRuntimeReferenceUpdates));
}

} // namespace reanimated
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ namespace reanimated {
using PropsMap = std::unordered_map<const ShadowNodeFamily *, std::vector<RawProps>>;
using ChildrenMap = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;

RootShadowNode::Unshared cloneShadowTreeWithNewProps(const RootShadowNode &oldRootNode, const PropsMap &propsMap);
RootShadowNode::Unshared cloneShadowTreeWithNewProps(
const RootShadowNode &oldRootNode,
const PropsMap &propsMap,
bool enableRuntimeReferenceUpdates);

} // namespace reanimated
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void LayoutAnimationsProxyCommon::restoreOpacityInCaseOfFlakyEnteringAnimation(S
propsMap[&targetShadowNode->getFamily()].emplace_back(folly::dynamic::object("opacity", opacity));
}
}
return cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
return cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap, false);
},
{});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1168,7 +1168,7 @@ void ReanimatedModuleProxy::commitUpdates(jsi::Runtime &rt, const UpdatesBatch &
return nullptr;
}

auto rootNode = cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap);
auto rootNode = cloneShadowTreeWithNewProps(oldRootShadowNode, propsMap, false);

// Mark the commit as Reanimated commit so that we can distinguish
// it in ReanimatedCommitHook.
Expand Down
Loading