Skip to content

Conversation

sebmarkbage
Copy link
Collaborator

Before the first rAF, we don't know if there has been other paints before this and if so when. (We could get from performance observer.) We can assume that it's not earlier than 0 so we used delay up until the throttle time starting from zero but if the first paint is about to happen that can be very soon after.

Instead, this reveals it during the next paint which should let us be able to get into the first paint. If we can trust rel="expect" to have done its thing we should schedule our raf before first paint but ofc browsers can cheat and paint earlier if they want to.

If we're wrong, this is at least more batched than doing it synchronously. However it will mean that things might get more flashy than it should be if it would've been throttled. An alternative would be to always throttle first reveal.

@sebmarkbage sebmarkbage requested a review from gnoff August 18, 2025 22:10
@meta-cla meta-cla bot added the CLA Signed label Aug 18, 2025
@github-actions github-actions bot added the React Core Team Opened by a member of the React Core Team label Aug 18, 2025
@react-sizebot
Copy link

react-sizebot commented Aug 18, 2025

Comparing: f508edc...7290ff0

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 +0.05% 1.83 kB 1.83 kB
oss-stable/react-dom/cjs/react-dom-client.production.js = 530.18 kB 530.18 kB = 93.39 kB 93.39 kB
oss-experimental/react-dom/cjs/react-dom.production.js = 6.69 kB 6.69 kB +0.11% 1.83 kB 1.83 kB
oss-experimental/react-dom/cjs/react-dom-client.production.js = 655.81 kB 655.81 kB = 115.30 kB 115.31 kB
facebook-www/ReactDOM-prod.classic.js = 675.58 kB 675.58 kB = 118.54 kB 118.54 kB
facebook-www/ReactDOM-prod.modern.js = 666.00 kB 666.00 kB = 116.86 kB 116.87 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 +0.44% 18.37 kB 18.45 kB +0.07% 4.14 kB 4.14 kB

Generated by 🚫 dangerJS against 7290ff0

@sebmarkbage sebmarkbage merged commit 0bdb920 into facebook:main Aug 19, 2025
241 checks passed
github-actions bot pushed a commit that referenced this pull request Aug 19, 2025
…t paint (#34230)

Before the first rAF, we don't know if there has been other paints
before this and if so when. (We could get from performance observer.) We
can assume that it's not earlier than 0 so we used delay up until the
throttle time starting from zero but if the first paint is about to
happen that can be very soon after.

Instead, this reveals it during the next paint which should let us be
able to get into the first paint. If we can trust `rel="expect"` to have
done its thing we should schedule our raf before first paint but ofc
browsers can cheat and paint earlier if they want to.

If we're wrong, this is at least more batched than doing it
synchronously. However it will mean that things might get more flashy
than it should be if it would've been throttled. An alternative would be
to always throttle first reveal.

DiffTrain build for [0bdb920](0bdb920)
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.

3 participants