From 3d166a0a4c08fdaae9174625d7baba247f84fdea Mon Sep 17 00:00:00 2001 From: Valentin Shergin Date: Sat, 16 Jan 2021 15:51:22 -0800 Subject: [PATCH] Fabric: Using ShadowNodeTraits::Trait::MeasurableYogaNode in TextInput Summary: It is the correct way to deal with the measure function. I believe it can fix the crash we see with TextInput state update. The crash is probably caused by invalid value of `shadowNodeRawPtr` in `YogaLayoutableShadowNode::yogaNodeCloneCallbackConnector`. It's hard to reconstruct the full chain of events but I think it's related: Yoga's dirty flag influences cloning, so the improper setting of this flag can misalign "natural" ShadowNode cloning (influenced by changes in the tree) and YGNode-initiated cloning (triggered by layout process). Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D25937710 fbshipit-source-id: a4e7c9dd8f5e6598fc662f4c6ee8061fd795e20d --- .../textinput/iostextinput/TextInputComponentDescriptor.h | 2 -- .../components/textinput/iostextinput/TextInputShadowNode.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h index 9614fd5712d..55b4d8afa1b 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h @@ -34,8 +34,6 @@ class TextInputComponentDescriptor final std::static_pointer_cast(shadowNode); concreteShadowNode->setTextLayoutManager(textLayoutManager_); - concreteShadowNode->dirtyLayout(); - concreteShadowNode->enableMeasurement(); } private: diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h index 4924c4f8b6b..8974372c317 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputShadowNode.h @@ -37,6 +37,7 @@ class TextInputShadowNode : public ConcreteViewShadowNode< auto traits = ConcreteViewShadowNode::BaseTraits(); traits.set(ShadowNodeTraits::Trait::TextKind); traits.set(ShadowNodeTraits::Trait::LeafYogaNode); + traits.set(ShadowNodeTraits::Trait::MeasurableYogaNode); return traits; }