From c7cf3e0cd534341dc0a32093aa250086c190e6c4 Mon Sep 17 00:00:00 2001 From: Nick Gerleman Date: Mon, 16 Oct 2023 17:01:27 -0700 Subject: [PATCH] Silence assert triggered by background executor race condition (#40895) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/40895 This is a long running debug assert due to a race condition with BE. I have at times wanted to try to add a lock to protect this, and measure impact, but really it will go away when we get rid of BE anyway, and any strategy I have come up with to lock gets hairy quickly. This change does not impact RN in OSS, where BE is already disabled. Changelog: [Internal] Reviewed By: rshest Differential Revision: D50247680 fbshipit-source-id: d004fc7db24f1f0b7c3ea8756d4678ce41579712 --- .../components/view/YogaLayoutableShadowNode.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp index 1aa2de1d98e5d5..3bfa3a97f2394f 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp +++ b/packages/react-native/ReactCommon/react/renderer/components/view/YogaLayoutableShadowNode.cpp @@ -106,14 +106,20 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode( yogaConfig_(FabricDefaultYogaLog), yogaNode_(static_cast(sourceShadowNode) .yogaNode_) { - // Note, cloned `yoga::Node` instance (copied using copy-constructor) inherits - // dirty flag, measure function, and other properties being set originally in - // the `YogaLayoutableShadowNode` constructor above. - +// Note, cloned `yoga::Node` instance (copied using copy-constructor) inherits +// dirty flag, measure function, and other properties being set originally in +// the `YogaLayoutableShadowNode` constructor above. + +// There is a known race condition when background executor is enabled, where +// a tree may be laid out on the Fabric background thread concurrently with +// the ShadowTree being created on the JS thread. This assert can be +// re-enabled after disabling background executor everywhere. +#if 0 react_native_assert( static_cast(sourceShadowNode) .yogaNode_.isDirty() == yogaNode_.isDirty() && "Yoga node must inherit dirty flag."); +#endif if (!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) { for (auto& child : getChildren()) {