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

Bugfix: Effects should never have higher than normal priority #16257

Merged
merged 2 commits into from
Jul 30, 2019

Conversation

acdlite
Copy link
Collaborator

@acdlite acdlite commented Jul 30, 2019

The priority of passive effects is supposed to be the same as the priority of the render. (That was the original intended behavior, at least.) The first commit fixes a bug where the priority is sometimes wrong if the effects are flushed early.

However, the priority should really never be higher than Normal Priority.

The second commit changes the behavior so that effects always have normal priority, or lower if the render priority is lower (e.g. offscreen prerendering).

The implementation is a bit awkward because of the way renderRoot, commitRoot, and flushPassiveEffects are split. This is a known factoring problem that I'm planning to address once 16.9 is released.

The priority of passive effects is supposed to be the same as the
priority of the render. This fixes a bug where the priority is sometimes
wrong if the effects are flushed early.

But the priority should really never be higher than Normal Priority.
I'll change that in the next commit.
@sizebot
Copy link

sizebot commented Jul 30, 2019

ReactDOM: size: 0.0%, gzip: -0.0%

Details of bundled changes.

Comparing: e276a5e...2950dbf

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 642.29 KB 642.84 KB 139.99 KB 140.08 KB UMD_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.2% 102.49 KB 102.59 KB 31.25 KB 31.32 KB UMD_PROD
react-art.development.js +0.1% +0.1% 573.16 KB 573.7 KB 122.7 KB 122.79 KB NODE_DEV
react-art.production.min.js 🔺+0.1% 🔺+0.1% 67.53 KB 67.63 KB 20.6 KB 20.63 KB NODE_PROD
ReactART-dev.js +0.1% +0.1% 586.95 KB 587.53 KB 122.26 KB 122.37 KB FB_WWW_DEV
ReactART-prod.js 🔺+0.3% 🔺+0.3% 220.49 KB 221.15 KB 37.6 KB 37.73 KB FB_WWW_PROD

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 271.99 KB 272.65 KB 46.7 KB 46.82 KB RN_OSS_PROD
ReactNativeRenderer-profiling.js +0.2% +0.1% 280.57 KB 281.07 KB 48.27 KB 48.34 KB RN_OSS_PROFILING
ReactFabric-prod.js 🔺+0.2% 🔺+0.3% 265.67 KB 266.33 KB 45.74 KB 45.86 KB RN_OSS_PROD
ReactFabric-profiling.js +0.2% +0.2% 274.53 KB 275 KB 47.24 KB 47.31 KB RN_OSS_PROFILING
ReactFabric-dev.js +0.1% +0.1% 733.68 KB 734.26 KB 154.97 KB 155.08 KB RN_FB_DEV
ReactFabric-prod.js 🔺+0.2% 🔺+0.3% 265.67 KB 266.34 KB 45.75 KB 45.87 KB RN_FB_PROD
ReactNativeRenderer-dev.js +0.1% +0.1% 720.97 KB 721.54 KB 152.51 KB 152.63 KB RN_OSS_DEV
ReactFabric-profiling.js +0.2% +0.2% 274.53 KB 275 KB 47.25 KB 47.32 KB RN_FB_PROFILING
ReactNativeRenderer-dev.js +0.1% +0.1% 721.06 KB 721.63 KB 152.56 KB 152.67 KB RN_FB_DEV
ReactNativeRenderer-prod.js 🔺+0.2% 🔺+0.2% 271.99 KB 272.65 KB 46.71 KB 46.82 KB RN_FB_PROD
ReactNativeRenderer-profiling.js +0.2% +0.1% 280.56 KB 281.06 KB 48.28 KB 48.35 KB RN_FB_PROFILING
ReactFabric-dev.js +0.1% +0.1% 733.58 KB 734.15 KB 154.93 KB 155.04 KB RN_OSS_DEV

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.profiling.min.js +0.1% +0.1% 115.23 KB 115.32 KB 36.25 KB 36.3 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 136.79 KB 136.79 KB 36.14 KB 36.14 KB UMD_DEV
ReactDOM-dev.js +0.1% +0.1% 929.97 KB 930.54 KB 205.61 KB 205.72 KB FB_WWW_DEV
react-dom-server.browser.production.min.js 0.0% -0.0% 19.35 KB 19.35 KB 7.24 KB 7.24 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% +0.1% 3.78 KB 3.78 KB 1.52 KB 1.52 KB UMD_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 11.19 KB 11.19 KB 4.11 KB 4.11 KB UMD_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 3.61 KB 3.61 KB 1.48 KB 1.47 KB NODE_DEV
react-dom-test-utils.production.min.js 0.0% -0.0% 10.97 KB 10.97 KB 4.04 KB 4.04 KB NODE_PROD
react-dom.development.js +0.1% 0.0% 906.65 KB 907.19 KB 205.29 KB 205.39 KB UMD_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.2% 111.52 KB 111.63 KB 35.81 KB 35.89 KB UMD_PROD
react-dom.profiling.min.js +0.1% +0.1% 114.96 KB 115.04 KB 36.84 KB 36.87 KB UMD_PROFILING
react-dom.development.js +0.1% 0.0% 900.94 KB 901.48 KB 203.81 KB 203.91 KB NODE_DEV
react-dom-server.node.development.js 0.0% 0.0% 134.85 KB 134.85 KB 35.75 KB 35.76 KB NODE_DEV
react-dom.production.min.js 🔺+0.1% 🔺+0.1% 111.57 KB 111.67 KB 35.3 KB 35.34 KB NODE_PROD
ReactDOM-prod.js 🔺+0.2% 🔺+0.2% 372.71 KB 373.44 KB 68.49 KB 68.59 KB FB_WWW_PROD
ReactDOM-profiling.js +0.1% +0.1% 377.61 KB 378.09 KB 69.56 KB 69.66 KB FB_WWW_PROFILING
react-dom-server.browser.development.js 0.0% 0.0% 132.92 KB 132.92 KB 35.22 KB 35.22 KB NODE_DEV
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.76 KB 60.76 KB 15.85 KB 15.85 KB UMD_DEV
react-dom-unstable-native-dependencies.production.min.js 0.0% -0.0% 10.74 KB 10.74 KB 3.68 KB 3.68 KB UMD_PROD
react-dom-unstable-native-dependencies.development.js 0.0% -0.0% 60.43 KB 60.43 KB 15.72 KB 15.72 KB NODE_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactTestRenderer-dev.js +0.1% +0.1% 598.74 KB 599.31 KB 124.95 KB 125.06 KB FB_WWW_DEV
react-test-renderer-shallow.development.js 0.0% -0.0% 39.37 KB 39.37 KB 9.92 KB 9.92 KB UMD_DEV
react-test-renderer-shallow.production.min.js 0.0% -0.1% 11.77 KB 11.77 KB 3.67 KB 3.67 KB NODE_PROD
react-test-renderer.development.js +0.1% +0.1% 586.92 KB 587.46 KB 125.58 KB 125.68 KB UMD_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 69.04 KB 69.14 KB 21.1 KB 21.14 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 582.46 KB 583 KB 124.47 KB 124.56 KB NODE_DEV
react-test-renderer.production.min.js 🔺+0.1% 🔺+0.2% 68.79 KB 68.88 KB 20.9 KB 20.93 KB NODE_PROD

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.1% 571.24 KB 571.79 KB 121.2 KB 121.31 KB NODE_DEV
react-reconciler.production.min.js 🔺+0.2% 🔺+0.1% 68.75 KB 68.85 KB 20.44 KB 20.47 KB NODE_PROD
react-reconciler-persistent.development.js +0.1% +0.1% 568.39 KB 568.94 KB 120.02 KB 120.11 KB NODE_DEV
react-reconciler-persistent.production.min.js 🔺+0.2% 🔺+0.2% 68.76 KB 68.86 KB 20.44 KB 20.47 KB NODE_PROD

Generated by 🚫 dangerJS

@acdlite
Copy link
Collaborator Author

acdlite commented Jul 30, 2019

There's a test failing; will look when I get back from coffee

Update: Fixed

Effects currently have the same priority as the render that spawns them.
This changes the behavior so that effects always have normal priority,
or lower if the render priority is lower (e.g. offscreen prerendering).

The implementation is a bit awkward because of the way `renderRoot`,
`commitRoot`, and `flushPassiveEffects` are split. This is a known
factoring problem that I'm planning to address once 16.9 is released.
@@ -213,7 +256,4 @@ describe('ReactSchedulerIntegration', () => {
Scheduler.unstable_flushUntilNextPaint();
expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
});

// TODO
it.skip('passive effects have render priority even if they are flushed early', () => {});
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should probably conduct regular audits of our TODOs :D

@acdlite acdlite merged commit f440bfd into facebook:master Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants