Feature flag: Use custom requestIdleCallback even when native one exists (#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.
This commit is contained in:
Andrew Clark
2018-03-15 19:28:21 -07:00
committed by GitHub
parent 208b490ed9
commit 7e87df8090
6 changed files with 8 additions and 0 deletions
@@ -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';
@@ -69,6 +70,7 @@ if (!ExecutionEnvironment.canUseDOM) {
clearTimeout(timeoutID);
};
} else if (
alwaysUseRequestIdleCallbackPolyfill ||
typeof requestIdleCallback !== 'function' ||
typeof cancelIdleCallback !== 'function'
) {
+2
View File
@@ -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.');
@@ -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() {
@@ -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() {
@@ -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() {
@@ -17,6 +17,7 @@ export const {
debugRenderPhaseSideEffectsForStrictMode,
warnAboutDeprecatedLifecycles,
replayFailedUnitOfWorkWithInvokeGuardedCallback,
alwaysUseRequestIdleCallbackPolyfill,
} = require('ReactFeatureFlags');
// The rest of the flags are static for better dead code elimination.