File tree Expand file tree Collapse file tree 3 files changed +19
-16
lines changed
packages/react-native-reanimated/Common/cpp/reanimated Expand file tree Collapse file tree 3 files changed +19
-16
lines changed Original file line number Diff line number Diff line change @@ -57,25 +57,24 @@ void UpdatesRegistryManager::unmarkNodeAsRemovable(Tag viewTag) {
57
57
58
58
void UpdatesRegistryManager::handleNodeRemovals (
59
59
const RootShadowNode &rootShadowNode) {
60
- for (auto it = removableShadowNodes_.begin ();
61
- it != removableShadowNodes_.end ();) {
62
- const auto &shadowNode = it->second ;
63
- const auto &family = shadowNode->getFamily ();
64
- const auto &ancestors = family.getAncestors (rootShadowNode);
65
-
66
- // Skip if the node hasn't been removed
67
- if (!ancestors.empty ()) {
68
- ++it;
60
+ RemovableShadowNodes remainingShadowNodes;
61
+
62
+ for (const auto &[tag, shadowNode] : removableShadowNodes_) {
63
+ if (!shadowNode) {
69
64
continue ;
70
65
}
71
66
72
- const auto tag = shadowNode->getTag ();
73
- for (auto ®istry : registries_) {
74
- registry->remove (tag);
67
+ if (shadowNode->getFamily ().getAncestors (rootShadowNode).empty ()) {
68
+ for (auto ®istry : registries_) {
69
+ registry->remove (tag);
70
+ }
71
+ staticPropsRegistry_->remove (tag);
72
+ } else {
73
+ remainingShadowNodes.emplace (tag, shadowNode);
75
74
}
76
- staticPropsRegistry_->remove (tag);
77
- it = removableShadowNodes_.erase (it);
78
75
}
76
+
77
+ removableShadowNodes_ = std::move (remainingShadowNodes);
79
78
}
80
79
81
80
PropsMap UpdatesRegistryManager::collectProps () {
Original file line number Diff line number Diff line change @@ -45,11 +45,13 @@ class UpdatesRegistryManager {
45
45
#endif
46
46
47
47
private:
48
+ using RemovableShadowNodes =
49
+ std::unordered_map<Tag, std::shared_ptr<const ShadowNode>>;
50
+
48
51
mutable std::mutex mutex_;
49
52
std::atomic<bool > isPaused_;
50
53
std::atomic<bool > shouldCommitAfterPause_;
51
- std::unordered_map<Tag, std::shared_ptr<const ShadowNode>>
52
- removableShadowNodes_;
54
+ RemovableShadowNodes removableShadowNodes_;
53
55
std::vector<std::shared_ptr<UpdatesRegistry>> registries_;
54
56
const std::shared_ptr<StaticPropsRegistry> staticPropsRegistry_;
55
57
Original file line number Diff line number Diff line change @@ -408,13 +408,15 @@ void ReanimatedModuleProxy::setViewStyle(
408
408
void ReanimatedModuleProxy::markNodeAsRemovable (
409
409
jsi::Runtime &rt,
410
410
const jsi::Value &shadowNodeWrapper) {
411
+ auto lock = updatesRegistryManager_->lock ();
411
412
auto shadowNode = shadowNodeFromValue (rt, shadowNodeWrapper);
412
413
updatesRegistryManager_->markNodeAsRemovable (shadowNode);
413
414
}
414
415
415
416
void ReanimatedModuleProxy::unmarkNodeAsRemovable (
416
417
jsi::Runtime &rt,
417
418
const jsi::Value &viewTag) {
419
+ auto lock = updatesRegistryManager_->lock ();
418
420
updatesRegistryManager_->unmarkNodeAsRemovable (viewTag.asNumber ());
419
421
}
420
422
You can’t perform that action at this time.
0 commit comments