Skip to content

[Fizz] Suspensey Images for View Transition Reveals #33433

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

Merged
merged 1 commit into from
Jun 6, 2025

Conversation

sebmarkbage
Copy link
Collaborator

Block the view transition on suspensey images Up to 500ms just like the client.

We can't use decode() because a bug in Chrome where those are blocked on startViewTransition finishing we instead rely on sync decoding but also that the image is live when it's animating in and we assume it doesn't start visible.

However, we can block the View Transition from starting on the "load" or "error" events.

The nice thing about blocking inside startViewTransition is that we have already done the layout so we can only wait on images that are within the viewport at this point. We might want to do that in Fiber too. If many image doesn't have fixed size but need to load first, they can all end up in the viewport. We might consider only doing this for images that have a fixed size or only a max number that doesn't have a fixed size.

@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Jun 4, 2025
@react-sizebot
Copy link

react-sizebot commented Jun 4, 2025

Comparing: d742611...fc19d72

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 = 530.07 kB 530.07 kB = 93.57 kB 93.57 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 = 651.16 kB 651.16 kB = 114.70 kB 114.70 kB
facebook-www/ReactDOM-prod.classic.js = 676.11 kB 676.11 kB = 118.97 kB 118.97 kB
facebook-www/ReactDOM-prod.modern.js = 666.39 kB 666.39 kB = 117.36 kB 117.36 kB
oss-experimental/react-dom/unstable_server-external-runtime.js +12.60% 15.86 kB 17.86 kB +9.14% 3.71 kB 4.05 kB

Significant size changes

Includes any change greater than 0.2%:

Expand to show
Name +/- Base Current +/- gzip Base gzip Current gzip
oss-experimental/react-dom/unstable_server-external-runtime.js +12.60% 15.86 kB 17.86 kB +9.14% 3.71 kB 4.05 kB
oss-experimental/react-dom/cjs/react-dom-server.node.production.js +0.90% 291.75 kB 294.38 kB +0.75% 51.72 kB 52.10 kB
oss-experimental/react-markup/cjs/react-markup.production.js +0.33% 246.99 kB 247.81 kB +0.51% 45.07 kB 45.30 kB
facebook-www/ReactDOMServer-prod.modern.js +0.33% 247.23 kB 248.05 kB +0.56% 44.36 kB 44.61 kB
facebook-www/ReactDOMServer-prod.classic.js +0.32% 252.68 kB 253.50 kB +0.55% 45.09 kB 45.34 kB
facebook-www/ReactDOMServerStreaming-prod.modern.js +0.32% 258.49 kB 259.31 kB +0.52% 47.08 kB 47.32 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.browser.production.js +0.31% 260.23 kB 261.05 kB +0.54% 46.12 kB 46.37 kB
oss-experimental/react-dom/cjs/react-dom-server-legacy.node.production.js +0.31% 265.30 kB 266.12 kB +0.51% 48.03 kB 48.27 kB
oss-experimental/react-dom/cjs/react-dom-server.bun.production.js +0.30% 270.70 kB 271.51 kB +0.48% 48.28 kB 48.51 kB
oss-experimental/react-markup/cjs/react-markup.react-server.production.js +0.24% 348.02 kB 348.84 kB +0.35% 64.38 kB 64.61 kB
oss-experimental/react-markup/cjs/react-markup.development.js +0.21% 390.87 kB 391.68 kB +0.33% 70.13 kB 70.36 kB
facebook-www/ReactDOMServerStreaming-dev.modern.js +0.20% 404.22 kB 405.04 kB +0.34% 72.25 kB 72.50 kB
oss-stable/react-dom/cjs/react-dom-server.node.development.js = 403.56 kB 401.50 kB = 72.57 kB 71.81 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.development.js = 403.48 kB 401.43 kB = 72.52 kB 71.76 kB
oss-stable/react-dom/cjs/react-dom-server.node.production.js = 255.44 kB 253.40 kB = 46.78 kB 45.92 kB
oss-stable-semver/react-dom/cjs/react-dom-server.node.production.js = 255.37 kB 253.33 kB = 46.75 kB 45.90 kB

Generated by 🚫 dangerJS against fc19d72

@sebmarkbage sebmarkbage force-pushed the fizzvtsuspensey2 branch 2 times, most recently from 2750ea2 to 9632c54 Compare June 4, 2025 04:24
Up to 500ms just like the client.
Hardanish-Singh

This comment was marked as spam.

@sebmarkbage
Copy link
Collaborator Author

One possible downside of this approach is that it may prevent interaction for the period it waits where if we wait before the startViewTransition then it remains interactive in the meantime.

@sebmarkbage sebmarkbage merged commit 22b9291 into facebook:main Jun 6, 2025
240 checks passed
github-actions bot pushed a commit that referenced this pull request Jun 6, 2025
Block the view transition on suspensey images Up to 500ms just like the
client.

We can't use `decode()` because a bug in Chrome where those are blocked
on `startViewTransition` finishing we instead rely on sync decoding but
also that the image is live when it's animating in and we assume it
doesn't start visible.

However, we can block the View Transition from starting on the `"load"`
or `"error"` events.

The nice thing about blocking inside `startViewTransition` is that we
have already done the layout so we can only wait on images that are
within the viewport at this point. We might want to do that in Fiber
too. If many image doesn't have fixed size but need to load first, they
can all end up in the viewport. We might consider only doing this for
images that have a fixed size or only a max number that doesn't have a
fixed size.

DiffTrain build for [22b9291](22b9291)
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