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

Fix development mode hang when iframe is removed #19220

Merged
merged 2 commits into from Jul 1, 2020

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Jun 30, 2020

Verified it fixes #16585.
Verified it fixes #16734.

Follows @sophiebits's suggestion in #16734 (comment).

This is a workaround for a Chrome bug that also exists in Safari and doesn't seem to be gaining momentum. The actual cases in which this happens may be niche but I have a hunch I've run into other manifestations of this issue so I think it's worth fixing.

The basic idea is that if our shim doesn't work, we fall back to prod behavior with a simple try/catch.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 30, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit af57488:

Sandbox Source
awesome-cohen-xst00 Configuration
React setState on hidden window hangs repro Issue #16585
romantic-nightingale-geiiu Issue #16734

@sizebot
Copy link

sizebot commented Jun 30, 2020

Details of bundled changes.

Comparing: 47ff31a...af57488

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% +0.1% 893.35 KB 893.87 KB 204.44 KB 204.55 KB NODE_DEV
react-dom-server.node.development.js 0.0% -0.0% 137.14 KB 137.14 KB 36.46 KB 36.46 KB NODE_DEV
react-dom.production.min.js 0.0% 0.0% 122.31 KB 122.31 KB 39.04 KB 39.04 KB NODE_PROD
react-dom-server.browser.development.js 0.0% 0.0% 143.24 KB 143.24 KB 36.67 KB 36.67 KB UMD_DEV
ReactDOMTesting-dev.js 0.0% 0.0% 979.55 KB 979.55 KB 220.02 KB 220.02 KB FB_WWW_DEV
react-dom-test-utils.development.js +0.7% +0.6% 70.08 KB 70.6 KB 19.59 KB 19.71 KB NODE_DEV
react-dom.development.js +0.1% +0.1% 938.93 KB 939.47 KB 207.09 KB 207.2 KB UMD_DEV
react-dom.profiling.min.js 0.0% 0.0% 126.08 KB 126.08 KB 41.09 KB 41.09 KB UMD_PROFILING
react-dom.profiling.min.js 0.0% 0.0% 126.39 KB 126.39 KB 40.25 KB 40.25 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 135.87 KB 135.87 KB 36.22 KB 36.21 KB NODE_DEV
react-dom-server.browser.production.min.js 0.0% 0.0% 19.8 KB 19.8 KB 7.43 KB 7.43 KB NODE_PROD
react-dom-test-utils.development.js +0.7% +0.6% 75.25 KB 75.79 KB 20.09 KB 20.22 KB UMD_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-art.development.js +0.1% +0.1% 664.43 KB 664.97 KB 141.33 KB 141.45 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 109.41 KB 109.41 KB 33.86 KB 33.86 KB UMD_PROD
react-art.development.js +0.1% +0.1% 566.9 KB 567.42 KB 123.53 KB 123.65 KB NODE_DEV
react-art.production.min.js 0.0% 0.0% 74.43 KB 74.43 KB 23.02 KB 23.02 KB NODE_PROD

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.73 KB 12.73 KB 3.96 KB 3.96 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 602.95 KB 603.5 KB 126.63 KB 126.74 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 76.59 KB 76.59 KB 23.96 KB 23.96 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 574.46 KB 574.97 KB 125.16 KB 125.28 KB NODE_DEV
ReactTestRenderer-dev.js 0.0% 0.0% 597.76 KB 597.76 KB 128.05 KB 128.05 KB FB_WWW_DEV
ReactTestRenderer-dev.js +0.1% +0.1% 590.83 KB 591.33 KB 127.77 KB 127.86 KB RN_FB_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 39.16 KB 39.16 KB 9.57 KB 9.57 KB UMD_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.1% 678.48 KB 678.98 KB 146.94 KB 147.04 KB RN_OSS_DEV
ReactFabric-dev.js +0.1% +0.1% 659.19 KB 659.69 KB 142.31 KB 142.42 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% 0.0% 265.67 KB 265.67 KB 46.99 KB 46.99 KB RN_OSS_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% 622.36 KB 622.88 KB 133.17 KB 133.3 KB NODE_DEV

Size changes (stable)

Generated by 🚫 dangerJS against af57488

@sizebot
Copy link

sizebot commented Jun 30, 2020

Details of bundled changes.

Comparing: 47ff31a...af57488

react-dom

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-dom.development.js +0.1% 0.0% 923.78 KB 924.3 KB 210.01 KB 210.12 KB NODE_DEV
ReactDOMForked-prod.js 0.0% 0.0% 395.65 KB 395.65 KB 73.42 KB 73.42 KB FB_WWW_PROD
react-dom-server.node.development.js 0.0% -0.0% 138.65 KB 138.65 KB 36.67 KB 36.67 KB NODE_DEV
react-dom-server.node.production.min.js 0.0% 0.0% 20.68 KB 20.68 KB 7.66 KB 7.66 KB NODE_PROD
react-dom-test-utils.production.min.js 0.0% 0.0% 13.18 KB 13.18 KB 4.9 KB 4.9 KB UMD_PROD
ReactDOMTesting-dev.js 0.0% 0.0% 953.75 KB 953.75 KB 214.36 KB 214.36 KB FB_WWW_DEV
react-dom-test-utils.development.js +0.7% +0.6% 70.09 KB 70.61 KB 19.6 KB 19.72 KB NODE_DEV
react-dom-unstable-fizz.node.production.min.js 0.0% 🔺+0.3% 1.17 KB 1.17 KB 666 B 668 B NODE_PROD
react-dom-unstable-fizz.browser.development.js 0.0% -0.1% 4.87 KB 4.87 KB 1.71 KB 1.7 KB NODE_DEV
react-dom.development.js +0.1% 0.0% 970.72 KB 971.26 KB 212.78 KB 212.89 KB UMD_DEV
ReactDOMForked-dev.js 0.0% 0.0% 973.36 KB 973.36 KB 217.34 KB 217.34 KB FB_WWW_DEV
react-dom.profiling.min.js 0.0% 0.0% 130.91 KB 130.91 KB 41.52 KB 41.52 KB NODE_PROFILING
react-dom-server.browser.development.js 0.0% -0.0% 137.38 KB 137.38 KB 36.42 KB 36.42 KB NODE_DEV
ReactDOMServer-dev.js 0.0% 0.0% 142.93 KB 142.93 KB 36.38 KB 36.38 KB FB_WWW_DEV
react-dom-test-utils.development.js +0.7% +0.6% 75.26 KB 75.81 KB 20.1 KB 20.22 KB UMD_DEV

react-native-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactNativeRenderer-dev.js +0.1% +0.1% 683.37 KB 683.87 KB 147.71 KB 147.82 KB RN_FB_DEV
ReactFabric-dev.js +0.1% +0.1% 664.09 KB 664.59 KB 143.09 KB 143.2 KB RN_FB_DEV
ReactNativeRenderer-dev.js +0.1% +0.1% 678.5 KB 678.99 KB 146.94 KB 147.05 KB RN_OSS_DEV
ReactFabric-prod.js 0.0% -0.0% 265.64 KB 265.64 KB 46.98 KB 46.98 KB RN_FB_PROD
ReactFabric-dev.js +0.1% +0.1% 659.21 KB 659.71 KB 142.32 KB 142.42 KB RN_OSS_DEV

react-art

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
ReactART-prod.js 0.0% -0.0% 240.28 KB 240.28 KB 42.46 KB 42.46 KB FB_WWW_PROD
react-art.development.js +0.1% +0.1% 686.59 KB 687.13 KB 145.41 KB 145.53 KB UMD_DEV
react-art.production.min.js 0.0% 0.0% 112.36 KB 112.36 KB 34.76 KB 34.77 KB UMD_PROD
react-art.development.js +0.1% +0.1% 588.15 KB 588.67 KB 127.56 KB 127.69 KB NODE_DEV

react-test-renderer

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-test-renderer-shallow.production.min.js 0.0% -0.0% 12.74 KB 12.74 KB 3.97 KB 3.97 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 602.98 KB 603.52 KB 126.64 KB 126.76 KB UMD_DEV
react-test-renderer.production.min.js 0.0% 0.0% 76.61 KB 76.61 KB 23.97 KB 23.97 KB UMD_PROD
react-test-renderer.development.js +0.1% +0.1% 574.48 KB 575 KB 125.17 KB 125.29 KB NODE_DEV
react-test-renderer.production.min.js 0.0% -0.0% 76.44 KB 76.44 KB 23.67 KB 23.67 KB NODE_PROD
ReactTestRenderer-dev.js 0.0% 0.0% 597.78 KB 597.78 KB 128.06 KB 128.06 KB FB_WWW_DEV
ReactTestRenderer-dev.js +0.1% +0.1% 590.84 KB 591.34 KB 127.78 KB 127.87 KB RN_FB_DEV
react-test-renderer-shallow.development.js 0.0% 0.0% 39.17 KB 39.17 KB 9.58 KB 9.58 KB UMD_DEV

react-reconciler

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
react-reconciler.development.js +0.1% +0.1% 645.97 KB 646.49 KB 137.68 KB 137.81 KB NODE_DEV
react-reconciler-reflection.development.js 0.0% 0.0% 16.7 KB 16.7 KB 4.98 KB 4.98 KB NODE_DEV

ReactDOM: size: 0.0%, gzip: 0.0%

Size changes (experimental)

Generated by 🚫 dangerJS against af57488

Copy link
Member

@rickhanlonii rickhanlonii left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -138,7 +133,15 @@ if (__DEV__) {
) {
window.event = windowEvent;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder why this doesn't do

if (windowEventDescriptor) {
    Object.defineProperty(window, 'event', windowEventDescriptor);
}

as below.

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 scared to touch it. #11696 (comment)

This was referenced Mar 15, 2021
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
5 participants