Skip to content

Commit

Permalink
Remove disableYielding feature flag (#15654)
Browse files Browse the repository at this point in the history
Obviated by Batched Mode.
  • Loading branch information
acdlite authored Jun 13, 2019
1 parent 4d949d7 commit e91dd70
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
'use strict';

const React = require('react');
const Fragment = React.Fragment;
let ReactFeatureFlags = require('shared/ReactFeatureFlags');

let ReactDOM;
Expand Down Expand Up @@ -602,84 +601,4 @@ describe('ReactDOMFiberAsync', () => {
expect(root.createBatch).toBe(undefined);
});
});

describe('Disable yielding', () => {
beforeEach(() => {
jest.resetModules();
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactFeatureFlags.disableYielding = true;
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
ReactDOM = require('react-dom');
Scheduler = require('scheduler');
});

it('wont yield during a render if yielding is disabled', () => {
class A extends React.Component {
render() {
Scheduler.yieldValue('A');
return <div>{this.props.children}</div>;
}
}

class B extends React.Component {
render() {
Scheduler.yieldValue('B');
return <div>{this.props.children}</div>;
}
}

class C extends React.Component {
render() {
Scheduler.yieldValue('C');
return <div>{this.props.children}</div>;
}
}

let root = ReactDOM.unstable_createRoot(container);

root.render(
<Fragment>
<A />
<B />
<C />
</Fragment>,
);

expect(Scheduler).toHaveYielded([]);

Scheduler.unstable_flushNumberOfYields(2);
// Even though we just flushed two yields, we should have rendered
// everything without yielding when the flag is on.
expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
});

it('wont suspend during a render if yielding is disabled', () => {
let p = new Promise(resolve => {});

function Suspend() {
throw p;
}

let root = ReactDOM.unstable_createRoot(container);
root.render(
<React.Suspense fallback={'Loading'}>Initial</React.Suspense>,
);

Scheduler.flushAll();
expect(container.textContent).toBe('Initial');

root.render(
<React.Suspense fallback={'Loading'}>
<Suspend />
</React.Suspense>,
);

expect(Scheduler).toHaveYielded([]);

Scheduler.flushAll();

// This should have flushed to the DOM even though we haven't ran the timers.
expect(container.textContent).toBe('Loading');
});
});
});
10 changes: 2 additions & 8 deletions packages/react-reconciler/src/ReactFiberWorkLoop.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
enableSuspenseServerRenderer,
replayFailedUnitOfWorkWithInvokeGuardedCallback,
enableProfilerTimer,
disableYielding,
enableSchedulerTracing,
revertPassiveEffectsChange,
} from 'shared/ReactFeatureFlags';
Expand Down Expand Up @@ -1004,7 +1003,7 @@ function renderRoot(
// possible.
const hasNotProcessedNewUpdates =
workInProgressRootLatestProcessedExpirationTime === Sync;
if (hasNotProcessedNewUpdates && !disableYielding && !isSync) {
if (hasNotProcessedNewUpdates && !isSync) {
// If we have not processed any new updates during this pass, then this is
// either a retry of an existing fallback state or a hidden tree.
// Hidden trees shouldn't be batched with other work and after that's
Expand Down Expand Up @@ -1041,7 +1040,7 @@ function renderRoot(
return commitRoot.bind(null, root);
}
case RootSuspendedWithDelay: {
if (!disableYielding && !isSync) {
if (!isSync) {
// We're suspended in a state that should be avoided. We'll try to avoid committing
// it for as long as the timeouts let us.
if (workInProgressRootHasPendingPing) {
Expand Down Expand Up @@ -2147,11 +2146,6 @@ function computeMsUntilSuspenseLoadingDelay(
committedExpirationTime: ExpirationTime,
suspenseConfig: SuspenseConfig,
) {
if (disableYielding) {
// Timeout immediately when yielding is disabled.
return 0;
}

const busyMinDurationMs = (suspenseConfig.busyMinDurationMs: any) | 0;
if (busyMinDurationMs <= 0) {
return 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
// CommonJS interop named imports.
import * as Scheduler from 'scheduler';
import {__interactionsRef} from 'scheduler/tracing';
import {
disableYielding,
enableSchedulerTracing,
} from 'shared/ReactFeatureFlags';
import {enableSchedulerTracing} from 'shared/ReactFeatureFlags';
import invariant from 'shared/invariant';

const {
Expand Down Expand Up @@ -65,9 +62,7 @@ export const IdlePriority: ReactPriorityLevel = 95;
// NoPriority is the absence of priority. Also React-only.
export const NoPriority: ReactPriorityLevel = 90;

export const shouldYield = disableYielding
? () => false // Never yield when `disableYielding` is on
: Scheduler_shouldYield;
export const shouldYield = Scheduler_shouldYield;

let syncQueue: Array<SchedulerCallback> | null = null;
let immediateQueueCallbackNode: mixed | null = null;
Expand Down
3 changes: 0 additions & 3 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ export function addUserTimingListener() {
// Disable javascript: URL strings in href for XSS protection.
export const disableJavaScriptURLs = false;

// Disables yielding during render in Concurrent Mode. Used for debugging only.
export const disableYielding = false;

// React Fire: prevent the value and checked attributes from syncing
// with their related DOM properties
export const disableInputAttributeSyncing = false;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-fb.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const warnAboutShorthandPropertyCollision = false;
export const enableSchedulerDebugging = false;
export const debugRenderPhaseSideEffectsForStrictMode = true;
export const disableJavaScriptURLs = false;
export const disableYielding = false;
export const disableInputAttributeSyncing = false;
export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
export const warnAboutDeprecatedLifecycles = true;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.native-oss.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableSchedulerTracing = __PROFILE__;
export const enableSuspenseServerRenderer = false;
export const disableJavaScriptURLs = false;
export const disableYielding = false;
export const disableInputAttributeSyncing = false;
export const enableStableConcurrentModeAPIs = false;
export const warnAboutShorthandPropertyCollision = false;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.persistent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const enableProfilerTimer = __PROFILE__;
export const enableSchedulerTracing = __PROFILE__;
export const enableSuspenseServerRenderer = false;
export const disableJavaScriptURLs = false;
export const disableYielding = false;
export const disableInputAttributeSyncing = false;
export const enableStableConcurrentModeAPIs = false;
export const warnAboutShorthandPropertyCollision = false;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.test-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export const enableProfilerTimer = false;
export const enableSchedulerTracing = false;
export const enableSuspenseServerRenderer = false;
export const disableJavaScriptURLs = false;
export const disableYielding = false;
export const disableInputAttributeSyncing = false;
export const enableStableConcurrentModeAPIs = false;
export const warnAboutShorthandPropertyCollision = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const enableStableConcurrentModeAPIs = false;
export const enableSchedulerDebugging = false;
export const warnAboutDeprecatedSetNativeProps = false;
export const disableJavaScriptURLs = false;
export const disableYielding = false;
export const enableEventAPI = true;
export const enableJSXTransformAPI = true;
export const warnAboutMissingMockScheduler = true;
Expand Down
1 change: 0 additions & 1 deletion packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const {
debugRenderPhaseSideEffectsForStrictMode,
replayFailedUnitOfWorkWithInvokeGuardedCallback,
warnAboutDeprecatedLifecycles,
disableYielding,
disableInputAttributeSyncing,
warnAboutShorthandPropertyCollision,
warnAboutDeprecatedSetNativeProps,
Expand Down

0 comments on commit e91dd70

Please sign in to comment.