@samitouri / QOS-React-2 / commits / e91dd70ba2

Remove disableYielding feature flag (#15654)

Obviated by Batched Mode.

Andrew Clark committed Jun 13, 2019 at 15:58 UTC e91dd70ba28e7a20da3e5de8d787f3cde56341bd
10 files changed +4 -105
packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js
-81
@@ -10,7 +10,6 @@
10 'use strict';
11
12 const React = require('react');
13 -const Fragment = React.Fragment;
13 let ReactFeatureFlags = require('shared/ReactFeatureFlags');
14
15 let ReactDOM;
@@ -602,84 +601,4 @@ describe('ReactDOMFiberAsync', () => {
601 expect(root.createBatch).toBe(undefined);
602 });
603 });
605 -
606 - describe('Disable yielding', () => {
607 - beforeEach(() => {
608 - jest.resetModules();
609 - ReactFeatureFlags = require('shared/ReactFeatureFlags');
610 - ReactFeatureFlags.disableYielding = true;
611 - ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
612 - ReactDOM = require('react-dom');
613 - Scheduler = require('scheduler');
614 - });
615 -
616 - it('wont yield during a render if yielding is disabled', () => {
617 - class A extends React.Component {
618 - render() {
619 - Scheduler.yieldValue('A');
620 - return <div>{this.props.children}</div>;
621 - }
622 - }
623 -
624 - class B extends React.Component {
625 - render() {
626 - Scheduler.yieldValue('B');
627 - return <div>{this.props.children}</div>;
628 - }
629 - }
630 -
631 - class C extends React.Component {
632 - render() {
633 - Scheduler.yieldValue('C');
634 - return <div>{this.props.children}</div>;
635 - }
636 - }
637 -
638 - let root = ReactDOM.unstable_createRoot(container);
639 -
640 - root.render(
641 - <Fragment>
642 - <A />
643 - <B />
644 - <C />
645 - </Fragment>,
646 - );
647 -
648 - expect(Scheduler).toHaveYielded([]);
649 -
650 - Scheduler.unstable_flushNumberOfYields(2);
651 - // Even though we just flushed two yields, we should have rendered
652 - // everything without yielding when the flag is on.
653 - expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
654 - });
655 -
656 - it('wont suspend during a render if yielding is disabled', () => {
657 - let p = new Promise(resolve => {});
658 -
659 - function Suspend() {
660 - throw p;
661 - }
662 -
663 - let root = ReactDOM.unstable_createRoot(container);
664 - root.render(
665 - <React.Suspense fallback={'Loading'}>Initial</React.Suspense>,
666 - );
667 -
668 - Scheduler.flushAll();
669 - expect(container.textContent).toBe('Initial');
670 -
671 - root.render(
672 - <React.Suspense fallback={'Loading'}>
673 - <Suspend />
674 - </React.Suspense>,
675 - );
676 -
677 - expect(Scheduler).toHaveYielded([]);
678 -
679 - Scheduler.flushAll();
680 -
681 - // This should have flushed to the DOM even though we haven't ran the timers.
682 - expect(container.textContent).toBe('Loading');
683 - });
684 - });
604 });
packages/react-reconciler/src/ReactFiberWorkLoop.js
+2 -8
@@ -23,7 +23,6 @@ import {
23 enableSuspenseServerRenderer,
24 replayFailedUnitOfWorkWithInvokeGuardedCallback,
25 enableProfilerTimer,
26 - disableYielding,
26 enableSchedulerTracing,
27 revertPassiveEffectsChange,
28 } from 'shared/ReactFeatureFlags';
@@ -1004,7 +1003,7 @@ function renderRoot(
1003 // possible.
1004 const hasNotProcessedNewUpdates =
1005 workInProgressRootLatestProcessedExpirationTime === Sync;
1007 - if (hasNotProcessedNewUpdates && !disableYielding && !isSync) {
1006 + if (hasNotProcessedNewUpdates && !isSync) {
1007 // If we have not processed any new updates during this pass, then this is
1008 // either a retry of an existing fallback state or a hidden tree.
1009 // Hidden trees shouldn't be batched with other work and after that's
@@ -1041,7 +1040,7 @@ function renderRoot(
1040 return commitRoot.bind(null, root);
1041 }
1042 case RootSuspendedWithDelay: {
1044 - if (!disableYielding && !isSync) {
1043 + if (!isSync) {
1044 // We're suspended in a state that should be avoided. We'll try to avoid committing
1045 // it for as long as the timeouts let us.
1046 if (workInProgressRootHasPendingPing) {
@@ -2147,11 +2146,6 @@ function computeMsUntilSuspenseLoadingDelay(
2146 committedExpirationTime: ExpirationTime,
2147 suspenseConfig: SuspenseConfig,
2148 ) {
2150 - if (disableYielding) {
2151 - // Timeout immediately when yielding is disabled.
2152 - return 0;
2153 - }
2154 -
2149 const busyMinDurationMs = (suspenseConfig.busyMinDurationMs: any) | 0;
2150 if (busyMinDurationMs <= 0) {
2151 return 0;
packages/react-reconciler/src/SchedulerWithReactIntegration.js
+2 -7
@@ -11,10 +11,7 @@
11 // CommonJS interop named imports.
12 import * as Scheduler from 'scheduler';
13 import {__interactionsRef} from 'scheduler/tracing';
14 -import {
15 - disableYielding,
16 - enableSchedulerTracing,
17 -} from 'shared/ReactFeatureFlags';
14 +import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
15 import invariant from 'shared/invariant';
16
17 const {
@@ -65,9 +62,7 @@ export const IdlePriority: ReactPriorityLevel = 95;
62 // NoPriority is the absence of priority. Also React-only.
63 export const NoPriority: ReactPriorityLevel = 90;
64
68 -export const shouldYield = disableYielding
69 - ? () => false // Never yield when `disableYielding` is on
70 - : Scheduler_shouldYield;
65 +export const shouldYield = Scheduler_shouldYield;
66
67 let syncQueue: Array<SchedulerCallback> | null = null;
68 let immediateQueueCallbackNode: mixed | null = null;
packages/shared/ReactFeatureFlags.js
-3
@@ -45,9 +45,6 @@ export function addUserTimingListener() {
45 // Disable javascript: URL strings in href for XSS protection.
46 export const disableJavaScriptURLs = false;
47
48 -// Disables yielding during render in Concurrent Mode. Used for debugging only.
49 -export const disableYielding = false;
50 -
48 // React Fire: prevent the value and checked attributes from syncing
49 // with their related DOM properties
50 export const disableInputAttributeSyncing = false;
packages/shared/forks/ReactFeatureFlags.native-fb.js
-1
@@ -27,7 +27,6 @@ export const warnAboutShorthandPropertyCollision = false;
27 export const enableSchedulerDebugging = false;
28 export const debugRenderPhaseSideEffectsForStrictMode = true;
29 export const disableJavaScriptURLs = false;
30 -export const disableYielding = false;
30 export const disableInputAttributeSyncing = false;
31 export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
32 export const warnAboutDeprecatedLifecycles = true;
packages/shared/forks/ReactFeatureFlags.native-oss.js
-1
@@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
21 export const enableSchedulerTracing = __PROFILE__;
22 export const enableSuspenseServerRenderer = false;
23 export const disableJavaScriptURLs = false;
24 -export const disableYielding = false;
24 export const disableInputAttributeSyncing = false;
25 export const enableStableConcurrentModeAPIs = false;
26 export const warnAboutShorthandPropertyCollision = false;
packages/shared/forks/ReactFeatureFlags.persistent.js
-1
@@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
21 export const enableSchedulerTracing = __PROFILE__;
22 export const enableSuspenseServerRenderer = false;
23 export const disableJavaScriptURLs = false;
24 -export const disableYielding = false;
24 export const disableInputAttributeSyncing = false;
25 export const enableStableConcurrentModeAPIs = false;
26 export const warnAboutShorthandPropertyCollision = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.js
-1
@@ -21,7 +21,6 @@ export const enableProfilerTimer = false;
21 export const enableSchedulerTracing = false;
22 export const enableSuspenseServerRenderer = false;
23 export const disableJavaScriptURLs = false;
24 -export const disableYielding = false;
24 export const disableInputAttributeSyncing = false;
25 export const enableStableConcurrentModeAPIs = false;
26 export const warnAboutShorthandPropertyCollision = false;
packages/shared/forks/ReactFeatureFlags.test-renderer.www.js
-1
@@ -27,7 +27,6 @@ export const enableStableConcurrentModeAPIs = false;
27 export const enableSchedulerDebugging = false;
28 export const warnAboutDeprecatedSetNativeProps = false;
29 export const disableJavaScriptURLs = false;
30 -export const disableYielding = false;
30 export const enableEventAPI = true;
31 export const enableJSXTransformAPI = true;
32 export const warnAboutMissingMockScheduler = true;
packages/shared/forks/ReactFeatureFlags.www.js
-1
@@ -16,7 +16,6 @@ export const {
16 debugRenderPhaseSideEffectsForStrictMode,
17 replayFailedUnitOfWorkWithInvokeGuardedCallback,
18 warnAboutDeprecatedLifecycles,
19 - disableYielding,
19 disableInputAttributeSyncing,
20 warnAboutShorthandPropertyCollision,
21 warnAboutDeprecatedSetNativeProps,