Skip to content

Commit

Permalink
Silence assert triggered by background executor race condition (faceb…
Browse files Browse the repository at this point in the history
…ook#40895)

Summary:
Pull Request resolved: facebook#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
  • Loading branch information
NickGerleman authored and facebook-github-bot committed Oct 17, 2023
1 parent 3bea8e1 commit c7cf3e0
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit c7cf3e0

Please sign in to comment.