Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make prerendering always non-blocking #31056

Merged
merged 2 commits into from
Sep 25, 2024

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Sep 24, 2024

Depends on


When a synchronous update suspends, and we prerender the siblings, the prerendering should be non-blocking so that we can immediately restart once the data arrives.

This happens automatically when there's a Suspense boundary, because we immediately commit the boundary and then proceed to a Retry render, which are always concurrent. When there's not a Suspense boundary, there is no Retry, so we need to take care to switch from the synchronous work loop to the concurrent one, to enable time slicing.

Copy link

vercel bot commented Sep 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-compiler-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 25, 2024 6:36pm

@react-sizebot
Copy link

react-sizebot commented Sep 24, 2024

Comparing: 3c7667a...7622167

Critical size changes

Includes critical production bundles, as well as any change greater than 2%:

Name +/- Base Current +/- gzip Base gzip Current gzip
oss-stable/react-dom/cjs/react-dom.production.js = 6.68 kB 6.68 kB = 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 508.43 kB 507.15 kB = 90.91 kB 90.79 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB = 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 513.37 kB 512.08 kB = 91.63 kB 91.52 kB
facebook-www/ReactDOM-prod.classic.js +0.12% 602.96 kB 603.67 kB +0.19% 106.63 kB 106.83 kB
facebook-www/ReactDOM-prod.modern.js +0.13% 579.15 kB 579.89 kB +0.19% 102.71 kB 102.91 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
facebook-www/ReactART-prod.modern.js +0.22% 352.31 kB 353.07 kB +0.31% 59.77 kB 59.95 kB
oss-experimental/react-art/cjs/react-art.development.js = 570.18 kB 568.98 kB = 92.24 kB 92.17 kB
react-native/implementations/ReactFabric-dev.js = 629.95 kB 628.51 kB = 103.24 kB 103.16 kB
react-native/implementations/ReactNativeRenderer-dev.js = 641.08 kB 639.55 kB = 105.25 kB 105.18 kB
oss-stable/react-dom/cjs/react-dom-profiling.profiling.js = 538.86 kB 537.57 kB = 95.70 kB 95.56 kB
oss-stable-rc/react-dom/cjs/react-dom-profiling.profiling.js = 538.76 kB 537.47 kB = 95.68 kB 95.54 kB
oss-stable-semver/react-dom/cjs/react-dom-profiling.profiling.js = 538.76 kB 537.47 kB = 95.68 kB 95.54 kB
oss-stable/react-reconciler/cjs/react-reconciler.development.js = 636.00 kB 634.45 kB = 102.17 kB 102.08 kB
oss-stable-rc/react-reconciler/cjs/react-reconciler.development.js = 635.98 kB 634.43 kB = 102.15 kB 102.06 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.development.js = 635.98 kB 634.43 kB = 102.15 kB 102.06 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js = 528.10 kB 526.81 kB = 95.26 kB 95.15 kB
oss-experimental/react-reconciler/cjs/react-reconciler.profiling.js = 422.76 kB 421.71 kB = 68.89 kB 68.85 kB
facebook-www/ReactTestRenderer-dev.classic.js = 573.17 kB 571.73 kB = 93.79 kB 93.67 kB
facebook-www/ReactTestRenderer-dev.modern.js = 573.16 kB 571.73 kB = 93.79 kB 93.67 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 513.37 kB 512.08 kB = 91.63 kB 91.52 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 508.43 kB 507.15 kB = 90.91 kB 90.79 kB
oss-stable-rc/react-dom/cjs/react-dom-client.production.js = 508.33 kB 507.04 kB = 90.88 kB 90.77 kB
oss-stable-semver/react-dom/cjs/react-dom-client.production.js = 508.33 kB 507.04 kB = 90.88 kB 90.77 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-dev.js = 578.95 kB 577.48 kB = 94.40 kB 94.31 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.development.js = 548.41 kB 546.97 kB = 89.67 kB 89.59 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.development.js = 545.85 kB 544.41 kB = 89.26 kB 89.19 kB
oss-stable-rc/react-test-renderer/cjs/react-test-renderer.development.js = 545.78 kB 544.35 kB = 89.24 kB 89.16 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.development.js = 545.78 kB 544.35 kB = 89.24 kB 89.16 kB
oss-stable/react-art/cjs/react-art.development.js = 552.99 kB 551.44 kB = 89.57 kB 89.47 kB
oss-stable-rc/react-art/cjs/react-art.development.js = 552.93 kB 551.38 kB = 89.54 kB 89.44 kB
oss-stable-semver/react-art/cjs/react-art.development.js = 552.93 kB 551.38 kB = 89.54 kB 89.44 kB
oss-stable/react-reconciler/cjs/react-reconciler.production.js = 384.49 kB 383.21 kB = 62.94 kB 62.86 kB
oss-stable-rc/react-reconciler/cjs/react-reconciler.production.js = 384.46 kB 383.19 kB = 62.92 kB 62.84 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.production.js = 384.46 kB 383.19 kB = 62.92 kB 62.84 kB
oss-experimental/react-reconciler/cjs/react-reconciler.production.js = 389.57 kB 388.27 kB = 63.77 kB 63.68 kB
oss-stable/react-reconciler/cjs/react-reconciler.profiling.js = 410.76 kB 409.39 kB = 66.66 kB 66.56 kB
oss-stable-rc/react-reconciler/cjs/react-reconciler.profiling.js = 410.74 kB 409.37 kB = 66.64 kB 66.54 kB
oss-stable-semver/react-reconciler/cjs/react-reconciler.profiling.js = 410.74 kB 409.37 kB = 66.64 kB 66.54 kB
react-native/implementations/ReactNativeRenderer-profiling.js = 385.02 kB 383.73 kB = 66.73 kB 66.66 kB
react-native/implementations/ReactFabric-profiling.js = 375.36 kB 374.07 kB = 64.96 kB 64.88 kB
react-native/implementations/ReactNativeRenderer-prod.js = 359.77 kB 358.49 kB = 62.96 kB 62.89 kB
react-native/implementations/ReactFabric-prod.js = 350.11 kB 348.82 kB = 61.31 kB 61.22 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-profiling.js = 344.80 kB 343.51 kB = 59.89 kB 59.82 kB
facebook-react-native/react-test-renderer/cjs/ReactTestRenderer-prod.js = 322.94 kB 321.66 kB = 56.86 kB 56.77 kB
oss-experimental/react-art/cjs/react-art.production.js = 302.84 kB 301.55 kB = 52.01 kB 51.93 kB
oss-stable/react-art/cjs/react-art.production.js = 298.33 kB 297.03 kB = 51.26 kB 51.16 kB
oss-stable-rc/react-art/cjs/react-art.production.js = 298.26 kB 296.97 kB = 51.24 kB 51.14 kB
oss-stable-semver/react-art/cjs/react-art.production.js = 298.26 kB 296.97 kB = 51.24 kB 51.14 kB
oss-experimental/react-test-renderer/cjs/react-test-renderer.production.js = 307.92 kB 306.55 kB = 54.44 kB 54.34 kB
oss-stable/react-test-renderer/cjs/react-test-renderer.production.js = 305.51 kB 304.14 kB = 53.98 kB 53.89 kB
oss-stable-rc/react-test-renderer/cjs/react-test-renderer.production.js = 305.44 kB 304.07 kB = 53.96 kB 53.87 kB
oss-stable-semver/react-test-renderer/cjs/react-test-renderer.production.js = 305.44 kB 304.07 kB = 53.96 kB 53.87 kB

Generated by 🚫 dangerJS against 4c71025

Neglected to wrap some places in the enableSiblingPrerendering flag.
When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.

This happens automatically when there's a Suspense boundary, because
we immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous
work loop to the concurrent one, to enable time slicing.
@acdlite acdlite force-pushed the nonblocking-sync-prerenders branch from a90a7b1 to 4c71025 Compare September 25, 2024 18:33
@acdlite acdlite merged commit 0f1856c into facebook:main Sep 25, 2024
185 checks passed
github-actions bot pushed a commit that referenced this pull request Sep 25, 2024
When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.

This happens automatically when there's a Suspense boundary, because we
immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

DiffTrain build for commit 0f1856c.
github-actions bot pushed a commit that referenced this pull request Sep 25, 2024
When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.

This happens automatically when there's a Suspense boundary, because we
immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

DiffTrain build for [0f1856c](0f1856c)
rickhanlonii added a commit that referenced this pull request Sep 26, 2024
poteto pushed a commit that referenced this pull request Sep 26, 2024
jackpope added a commit that referenced this pull request Oct 14, 2024
…flag checks (#31238)

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
2a9fb44
Revert PR: #31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>
github-actions bot pushed a commit that referenced this pull request Oct 14, 2024
…flag checks (#31238)

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
2a9fb44
Revert PR: #31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4](13411e4)
github-actions bot pushed a commit that referenced this pull request Oct 14, 2024
…flag checks (#31238)

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
2a9fb44
Revert PR: #31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4](13411e4)
github-actions bot pushed a commit to AnselK/react that referenced this pull request Oct 15, 2024
…flag checks (facebook#31238)

This is a partial re-land of
facebook#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: facebook#31056
Original Commit:
facebook@2a9fb44
Revert PR: facebook#31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4](facebook@13411e4)
github-actions bot pushed a commit to AnselK/react that referenced this pull request Oct 15, 2024
…flag checks (facebook#31238)

This is a partial re-land of
facebook#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: facebook#31056
Original Commit:
facebook@2a9fb44
Revert PR: facebook#31080

Commit description:
```
Neglected to wrap some places in the enableSiblingPrerendering flag.
```

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [13411e4](facebook@13411e4)
jackpope added a commit that referenced this pull request Oct 15, 2024
Follows #31238

___

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
4c71025
Revert PR: #31080

Commit description:

> When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.
>
> This happens automatically when there's a Suspense boundary, because
we immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

Co-authored-by: Andrew Clark <git@andrewclark.io>
github-actions bot pushed a commit that referenced this pull request Oct 15, 2024
Follows #31238

___

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
4c71025
Revert PR: #31080

Commit description:

> When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.
>
> This happens automatically when there's a Suspense boundary, because
we immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [6c4bbc7](6c4bbc7)
github-actions bot pushed a commit that referenced this pull request Oct 15, 2024
Follows #31238

___

This is a partial re-land of
#31056. We saw breakages surface
after the original land and had to revert. Now that they've been fixed,
let's try this again. This time we'll split up the commits to give us
more control of testing and rollout internally.

Original PR: #31056
Original Commit:
4c71025
Revert PR: #31080

Commit description:

> When a synchronous update suspends, and we prerender the siblings, the
prerendering should be non-blocking so that we can immediately restart
once the data arrives.
>
> This happens automatically when there's a Suspense boundary, because
we immediately commit the boundary and then proceed to a Retry render,
which are always concurrent. When there's not a Suspense boundary, there
is no Retry, so we need to take care to switch from the synchronous work
loop to the concurrent one, to enable time slicing.

Co-authored-by: Andrew Clark <git@andrewclark.io>

DiffTrain build for [6c4bbc7](6c4bbc7)

if (exitStatus !== RootInProgress) {
do {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving let renderWasConcurrent = shouldTimeSlice; inside of the do means the places it's set below won't matter (and GCC strips the assignments from the build).

This means when you hit the isRenderConsistentWithExternalStores case, it will get into a sync render loop if the exit status is RootSuspended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed React Core Team Opened by a member of the React Core Team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants