Skip to content

Commit

Permalink
[Fiber] clarify entry condition for suspensey commit recursion
Browse files Browse the repository at this point in the history
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
  • Loading branch information
gnoff committed May 23, 2024
1 parent 3ac551e commit 09f87eb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ import {
MountLayoutDev,
DidDefer,
ShouldSuspendCommit,
MaySuspendCommit,
} from './ReactFiberFlags';
import {
NoLanes,
Expand Down Expand Up @@ -1185,7 +1186,13 @@ function commitRootWhenReady(
) {
// TODO: Combine retry throttling with Suspensey commits. Right now they run
// one after the other.
if (finishedWork.subtreeFlags & ShouldSuspendCommit) {
const BothVisibilityAndMaySuspendCommit = Visibility | MaySuspendCommit;
const subtreeFlags = finishedWork.subtreeFlags;
if (
subtreeFlags & ShouldSuspendCommit ||
(subtreeFlags & BothVisibilityAndMaySuspendCommit) ===
BothVisibilityAndMaySuspendCommit
) {
// Before committing, ask the renderer whether the host tree is ready.
// If it's not, we'll wait until it notifies us.
startSuspendingCommit();
Expand Down

0 comments on commit 09f87eb

Please sign in to comment.