Skip to content

Commit 3e17cd4

Browse files
committed
feat: prevent ime crashes while merging folly
1 parent 69b094e commit 3e17cd4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

cxx/shadowTree/ShadowTreeManager.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ void shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
2222
for (const auto& [family, props] : updates) {
2323
tagToProps.insert({family->getTag(), props});
2424

25-
// Store in native props system to preserve during Reanimated cloning
26-
const_cast<ShadowNodeFamily*>(family)->nativeProps_DEPRECATED =
27-
std::make_unique<folly::dynamic>(props);
25+
auto* mutableFamily = const_cast<ShadowNodeFamily*>(family);
26+
27+
if (mutableFamily->nativeProps_DEPRECATED) {
28+
mutableFamily->nativeProps_DEPRECATED->update(props);
29+
} else {
30+
mutableFamily->nativeProps_DEPRECATED = std::make_unique<folly::dynamic>(props);
31+
}
2832
}
2933

3034
UIManagerBinding::getBinding(rt)->getUIManager().updateShadowTree(std::move(tagToProps));
@@ -40,8 +44,13 @@ void shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
4044

4145
for (const auto& [family, props] : updates) {
4246
// Merge props to fix glitches caused by REA updates
43-
const_cast<ShadowNodeFamily*>(family)->nativeProps_DEPRECATED =
44-
std::make_unique<folly::dynamic>(props);
47+
auto* mutableFamily = const_cast<ShadowNodeFamily*>(family);
48+
49+
if (mutableFamily->nativeProps_DEPRECATED) {
50+
mutableFamily->nativeProps_DEPRECATED->update(props);
51+
} else {
52+
mutableFamily->nativeProps_DEPRECATED = std::make_unique<folly::dynamic>(props);
53+
}
4554
}
4655

4756
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(

0 commit comments

Comments
 (0)