Skip to content

Commit

Permalink
Feature flag: Use custom requestIdleCallback even when native one exi…
Browse files Browse the repository at this point in the history
…sts (facebook#12385)

We'll use this in www to test whether the polyfill is better at
scheduling high-pri async work than the native one. My preliminary tests
suggest "yes" but it's hard to say for certain, given how difficult it
is to consistently reproduce the starvation issues we've been seeing.
  • Loading branch information
acdlite authored and rhagigi committed Apr 19, 2018
1 parent c2ec69a commit 726b47d
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/shared/ReactDOMFrameScheduling.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import type {Deadline} from 'react-reconciler';

import {alwaysUseRequestIdleCallbackPolyfill} from 'shared/ReactFeatureFlags';
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
import warning from 'fbjs/lib/warning';

Expand Down Expand Up @@ -69,6 +70,7 @@ if (!ExecutionEnvironment.canUseDOM) {
clearTimeout(timeoutID);
};
} else if (
alwaysUseRequestIdleCallbackPolyfill ||
typeof requestIdleCallback !== 'function' ||
typeof cancelIdleCallback !== 'function'
) {
Expand Down
2 changes: 2 additions & 0 deletions packages/shared/ReactFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
export const warnAboutDeprecatedLifecycles = false;

export const alwaysUseRequestIdleCallbackPolyfill = false;

// Only used in www builds.
export function addUserTimingListener() {
invariant(false, 'Not implemented.');
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native-fabric.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
export const enableMutatingReconciler = false;
export const enableNoopReconciler = false;
export const enablePersistentReconciler = true;
export const alwaysUseRequestIdleCallbackPolyfill = false;

// Only used in www builds.
export function addUserTimingListener() {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const enableUserTimingAPI = __DEV__;
export const enableMutatingReconciler = true;
export const enableNoopReconciler = false;
export const enablePersistentReconciler = false;
export const alwaysUseRequestIdleCallbackPolyfill = false;

// Only used in www builds.
export function addUserTimingListener() {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.persistent.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
export const enableMutatingReconciler = false;
export const enableNoopReconciler = false;
export const enablePersistentReconciler = true;
export const alwaysUseRequestIdleCallbackPolyfill = false;

// Only used in www builds.
export function addUserTimingListener() {
Expand Down
1 change: 1 addition & 0 deletions packages/shared/forks/ReactFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const {
debugRenderPhaseSideEffectsForStrictMode,
warnAboutDeprecatedLifecycles,
replayFailedUnitOfWorkWithInvokeGuardedCallback,
alwaysUseRequestIdleCallbackPolyfill,
} = require('ReactFeatureFlags');

// The rest of the flags are static for better dead code elimination.
Expand Down

0 comments on commit 726b47d

Please sign in to comment.