@samitouri / QOS-React / commits / 7e87df8090

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.

Andrew Clark committed Mar 15, 2018 at 19:28 UTC 7e87df809052bf4f861e61cf8c6ee58cbdcf9743
6 files changed +8
packages/shared/ReactDOMFrameScheduling.js
+2
@@ -17,6 +17,7 @@
17
18 import type {Deadline} from 'react-reconciler';
19
20 +import {alwaysUseRequestIdleCallbackPolyfill} from 'shared/ReactFeatureFlags';
21 import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
22 import warning from 'fbjs/lib/warning';
23
@@ -69,6 +70,7 @@ if (!ExecutionEnvironment.canUseDOM) {
70 clearTimeout(timeoutID);
71 };
72 } else if (
73 + alwaysUseRequestIdleCallbackPolyfill ||
74 typeof requestIdleCallback !== 'function' ||
75 typeof cancelIdleCallback !== 'function'
76 ) {
packages/shared/ReactFeatureFlags.js
+2
@@ -38,6 +38,8 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
38 // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
39 export const warnAboutDeprecatedLifecycles = false;
40
41 +export const alwaysUseRequestIdleCallbackPolyfill = false;
42 +
43 // Only used in www builds.
44 export function addUserTimingListener() {
45 invariant(false, 'Not implemented.');
packages/shared/forks/ReactFeatureFlags.native-fabric.js
+1
@@ -24,6 +24,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
24 export const enableMutatingReconciler = false;
25 export const enableNoopReconciler = false;
26 export const enablePersistentReconciler = true;
27 +export const alwaysUseRequestIdleCallbackPolyfill = false;
28
29 // Only used in www builds.
30 export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.native.js
+1
@@ -27,6 +27,7 @@ export const enableUserTimingAPI = __DEV__;
27 export const enableMutatingReconciler = true;
28 export const enableNoopReconciler = false;
29 export const enablePersistentReconciler = false;
30 +export const alwaysUseRequestIdleCallbackPolyfill = false;
31
32 // Only used in www builds.
33 export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.persistent.js
+1
@@ -25,6 +25,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
25 export const enableMutatingReconciler = false;
26 export const enableNoopReconciler = false;
27 export const enablePersistentReconciler = true;
28 +export const alwaysUseRequestIdleCallbackPolyfill = false;
29
30 // Only used in www builds.
31 export function addUserTimingListener() {
packages/shared/forks/ReactFeatureFlags.www.js
+1
@@ -17,6 +17,7 @@ export const {
17 debugRenderPhaseSideEffectsForStrictMode,
18 warnAboutDeprecatedLifecycles,
19 replayFailedUnitOfWorkWithInvokeGuardedCallback,
20 + alwaysUseRequestIdleCallbackPolyfill,
21 } = require('ReactFeatureFlags');
22
23 // The rest of the flags are static for better dead code elimination.