@samitouri / QOS-React-2 / commits / f55d172bcf

[Fiber] clarify entry condition for suspensey commit recursion (#29222)

Previously Suspensey recursion would only trigger if the ShouldSuspendCommit flag was true. However there is a dependence on the Visibility flag embedded in this logic because these flags share a bit. To make it clear that the semantics of Suspensey resources require considering both flags I've added it to the condition even though this extra or-ing is a noop when the bit is shared

Josh Story committed May 23, 2024 at 13:54 UTC f55d172bcf921d761733533395b798c5b3665e04
1 file changed +8 -1
packages/react-reconciler/src/ReactFiberWorkLoop.js
+8 -1
@@ -126,6 +126,7 @@ import {
126 MountLayoutDev,
127 DidDefer,
128 ShouldSuspendCommit,
129 + MaySuspendCommit,
130 } from './ReactFiberFlags';
131 import {
132 NoLanes,
@@ -1185,7 +1186,13 @@ function commitRootWhenReady(
1186 ) {
1187 // TODO: Combine retry throttling with Suspensey commits. Right now they run
1188 // one after the other.
1188 - if (finishedWork.subtreeFlags & ShouldSuspendCommit) {
1189 + const BothVisibilityAndMaySuspendCommit = Visibility | MaySuspendCommit;
1190 + const subtreeFlags = finishedWork.subtreeFlags;
1191 + if (
1192 + subtreeFlags & ShouldSuspendCommit ||
1193 + (subtreeFlags & BothVisibilityAndMaySuspendCommit) ===
1194 + BothVisibilityAndMaySuspendCommit
1195 + ) {
1196 // Before committing, ask the renderer whether the host tree is ready.
1197 // If it's not, we'll wait until it notifies us.
1198 startSuspendingCommit();