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
This commit is contained in:
Nick Gerleman
2023-10-16 17:01:27 -07:00
committed by Facebook GitHub Bot
parent 3bea8e1bd4
commit c7cf3e0cd5
@@ -106,14 +106,20 @@ YogaLayoutableShadowNode::YogaLayoutableShadowNode(
yogaConfig_(FabricDefaultYogaLog),
yogaNode_(static_cast<const YogaLayoutableShadowNode&>(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<const YogaLayoutableShadowNode&>(sourceShadowNode)
.yogaNode_.isDirty() == yogaNode_.isDirty() &&
"Yoga node must inherit dirty flag.");
#endif
if (!getTraits().check(ShadowNodeTraits::Trait::LeafYogaNode)) {
for (auto& child : getChildren()) {