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

[Fiber] Schedule passive effects using the regular ensureRootIsScheduled flow #31785

Merged
merged 4 commits into from
Dec 17, 2024

Conversation

sebmarkbage
Copy link
Collaborator

This treats workInProgressRoot work and rootWithPendingPassiveEffects the same way. Basically as long as there's some work on the root, yield the current task. Including passive effects. This means that passive effects are now a continuation instead of a separate callback. This can mean they're earlier or later than before. Later for Idle in case there's other non-React work. Earlier for same Default if there's other Default priority work.

This makes sense since increasing priority of the passive effects beyond Idle doesn't really make sense for an Idle render.

However, for any given render at same priority it's more important to complete this work than start something new.

Since we special case continuations to always yield to the browser, this has the same effect as #31784 without implementing requestPaint. At least assuming nothing else calls requestPaint.

Screenshot 2024-12-14 at 5 37 37 PM

Copy link

vercel bot commented Dec 14, 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 Dec 17, 2024 9:51pm

@facebook-github-bot facebook-github-bot added CLA Signed React Core Team Opened by a member of the React Core Team labels Dec 14, 2024
@@ -595,7 +597,7 @@ describe('useSubscription', () => {
React.startTransition(() => {
mutate('C');
});
await waitFor(['render:first:C', 'render:second:C']);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure about the intended semantics of waitFor but I'm confused it doesn't wait just as long or longer than waitForPaint.

@@ -755,10 +755,16 @@ describe('ReactExpiration', () => {

// The update finishes without yielding. But it does not flush the effect.
await waitFor(['B1'], {
additionalLogsAfterAttemptingToYield: ['C1'],
additionalLogsAfterAttemptingToYield: gate(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm not sure what the expected semantics of this helper is and whether this change is expected.

@@ -911,9 +911,7 @@ describe('ReactDOMSelect', () => {
const container = document.createElement('div');
const root = ReactDOMClient.createRoot(container);
async function changeView() {
await act(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This triggers the interleave act warning but that should've already happened before since the dispatch is wrapped by act. So this is fixing something but not sure why this wasn't already erroring before.

@react-sizebot
Copy link

react-sizebot commented Dec 14, 2024

Comparing: f5077bc...63391b6

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 +0.01% 510.66 kB 510.71 kB = 91.30 kB 91.29 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 +0.28% 515.44 kB 516.86 kB +0.10% 92.15 kB 92.24 kB
facebook-www/ReactDOM-prod.classic.js = 592.36 kB 592.42 kB +0.01% 104.36 kB 104.38 kB
facebook-www/ReactDOM-prod.modern.js = 582.63 kB 582.68 kB +0.01% 102.80 kB 102.82 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/cjs/react-dom-client.production.js +0.28% 515.44 kB 516.86 kB +0.10% 92.15 kB 92.24 kB
oss-experimental/react-dom/cjs/react-dom-unstable_testing.production.js +0.27% 530.17 kB 531.59 kB +0.06% 95.78 kB 95.83 kB
oss-experimental/react-dom/cjs/react-dom-profiling.profiling.js +0.21% 561.16 kB 562.33 kB = 99.68 kB 99.66 kB
oss-experimental/react-art/cjs/react-art.production.js +0.21% 303.73 kB 304.36 kB = 52.12 kB 52.00 kB

Generated by 🚫 dangerJS against 9b7be25

This treats workInProgressRoot work and rootWithPendingPassiveEffects the same way.

Basically as long as there's some work on the root, yield the current task.
Including passive effects.
The ReactDOMSelect has an overlapping act error but I don't know why that wasn't erroring before.

I also don't get why waitFor isn't enough for useSubscription.

Nor why ReactExpiration changes. What does the additionalLogsAfterAttemptingToYield helper do?
@sebmarkbage sebmarkbage merged commit facec3e into facebook:main Dec 17, 2024
187 checks passed
github-actions bot pushed a commit that referenced this pull request Dec 17, 2024
…led flow (#31785)

This treats workInProgressRoot work and rootWithPendingPassiveEffects
the same way. Basically as long as there's some work on the root, yield
the current task. Including passive effects. This means that passive
effects are now a continuation instead of a separate callback. This can
mean they're earlier or later than before. Later for Idle in case
there's other non-React work. Earlier for same Default if there's other
Default priority work.

This makes sense since increasing priority of the passive effects beyond
Idle doesn't really make sense for an Idle render.

However, for any given render at same priority it's more important to
complete this work than start something new.

Since we special case continuations to always yield to the browser, this
has the same effect as #31784 without implementing `requestPaint`. At
least assuming nothing else calls `requestPaint`.

<img width="587" alt="Screenshot 2024-12-14 at 5 37 37 PM"
src="https://github.com/user-attachments/assets/8641b172-8842-4191-8bf0-50cbe263a30c"
/>

DiffTrain build for [facec3e](facec3e)
github-actions bot pushed a commit that referenced this pull request Dec 17, 2024
…led flow (#31785)

This treats workInProgressRoot work and rootWithPendingPassiveEffects
the same way. Basically as long as there's some work on the root, yield
the current task. Including passive effects. This means that passive
effects are now a continuation instead of a separate callback. This can
mean they're earlier or later than before. Later for Idle in case
there's other non-React work. Earlier for same Default if there's other
Default priority work.

This makes sense since increasing priority of the passive effects beyond
Idle doesn't really make sense for an Idle render.

However, for any given render at same priority it's more important to
complete this work than start something new.

Since we special case continuations to always yield to the browser, this
has the same effect as #31784 without implementing `requestPaint`. At
least assuming nothing else calls `requestPaint`.

<img width="587" alt="Screenshot 2024-12-14 at 5 37 37 PM"
src="https://github.com/user-attachments/assets/8641b172-8842-4191-8bf0-50cbe263a30c"
/>

DiffTrain build for [facec3e](facec3e)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Dec 18, 2024
…led flow (facebook#31785)

This treats workInProgressRoot work and rootWithPendingPassiveEffects
the same way. Basically as long as there's some work on the root, yield
the current task. Including passive effects. This means that passive
effects are now a continuation instead of a separate callback. This can
mean they're earlier or later than before. Later for Idle in case
there's other non-React work. Earlier for same Default if there's other
Default priority work.

This makes sense since increasing priority of the passive effects beyond
Idle doesn't really make sense for an Idle render.

However, for any given render at same priority it's more important to
complete this work than start something new.

Since we special case continuations to always yield to the browser, this
has the same effect as facebook#31784 without implementing `requestPaint`. At
least assuming nothing else calls `requestPaint`.

<img width="587" alt="Screenshot 2024-12-14 at 5 37 37 PM"
src="https://github.com/user-attachments/assets/8641b172-8842-4191-8bf0-50cbe263a30c"
/>

DiffTrain build for [facec3e](facebook@facec3e)
github-actions bot pushed a commit to code/lib-react that referenced this pull request Dec 18, 2024
…led flow (facebook#31785)

This treats workInProgressRoot work and rootWithPendingPassiveEffects
the same way. Basically as long as there's some work on the root, yield
the current task. Including passive effects. This means that passive
effects are now a continuation instead of a separate callback. This can
mean they're earlier or later than before. Later for Idle in case
there's other non-React work. Earlier for same Default if there's other
Default priority work.

This makes sense since increasing priority of the passive effects beyond
Idle doesn't really make sense for an Idle render.

However, for any given render at same priority it's more important to
complete this work than start something new.

Since we special case continuations to always yield to the browser, this
has the same effect as facebook#31784 without implementing `requestPaint`. At
least assuming nothing else calls `requestPaint`.

<img width="587" alt="Screenshot 2024-12-14 at 5 37 37 PM"
src="https://github.com/user-attachments/assets/8641b172-8842-4191-8bf0-50cbe263a30c"
/>

DiffTrain build for [facec3e](facebook@facec3e)
jackpope added a commit that referenced this pull request Dec 20, 2024
#31785 turned on
`enableYieldingBeforePassive` for the internal test renderer builds. We
have some failing tests on the RN side blocking the sync so lets turn
these off for now.
github-actions bot pushed a commit that referenced this pull request Dec 20, 2024
#31785 turned on
`enableYieldingBeforePassive` for the internal test renderer builds. We
have some failing tests on the RN side blocking the sync so lets turn
these off for now.

DiffTrain build for [de82912](de82912)
github-actions bot pushed a commit that referenced this pull request Dec 20, 2024
#31785 turned on
`enableYieldingBeforePassive` for the internal test renderer builds. We
have some failing tests on the RN side blocking the sync so lets turn
these off for now.

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