Skip to content

Commit 7e87df8

Browse files
authored
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.
1 parent 208b490 commit 7e87df8

File tree

6 files changed

+8
-0
lines changed

6 files changed

+8
-0
lines changed

packages/shared/ReactDOMFrameScheduling.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

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

20+
import {alwaysUseRequestIdleCallbackPolyfill} from 'shared/ReactFeatureFlags';
2021
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
2122
import warning from 'fbjs/lib/warning';
2223

@@ -69,6 +70,7 @@ if (!ExecutionEnvironment.canUseDOM) {
6970
clearTimeout(timeoutID);
7071
};
7172
} else if (
73+
alwaysUseRequestIdleCallbackPolyfill ||
7274
typeof requestIdleCallback !== 'function' ||
7375
typeof cancelIdleCallback !== 'function'
7476
) {

packages/shared/ReactFeatureFlags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
3838
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
3939
export const warnAboutDeprecatedLifecycles = false;
4040

41+
export const alwaysUseRequestIdleCallbackPolyfill = false;
42+
4143
// Only used in www builds.
4244
export function addUserTimingListener() {
4345
invariant(false, 'Not implemented.');

packages/shared/forks/ReactFeatureFlags.native-fabric.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
2424
export const enableMutatingReconciler = false;
2525
export const enableNoopReconciler = false;
2626
export const enablePersistentReconciler = true;
27+
export const alwaysUseRequestIdleCallbackPolyfill = false;
2728

2829
// Only used in www builds.
2930
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.native.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const enableUserTimingAPI = __DEV__;
2727
export const enableMutatingReconciler = true;
2828
export const enableNoopReconciler = false;
2929
export const enablePersistentReconciler = false;
30+
export const alwaysUseRequestIdleCallbackPolyfill = false;
3031

3132
// Only used in www builds.
3233
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.persistent.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
2525
export const enableMutatingReconciler = false;
2626
export const enableNoopReconciler = false;
2727
export const enablePersistentReconciler = true;
28+
export const alwaysUseRequestIdleCallbackPolyfill = false;
2829

2930
// Only used in www builds.
3031
export function addUserTimingListener() {

packages/shared/forks/ReactFeatureFlags.www.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const {
1717
debugRenderPhaseSideEffectsForStrictMode,
1818
warnAboutDeprecatedLifecycles,
1919
replayFailedUnitOfWorkWithInvokeGuardedCallback,
20+
alwaysUseRequestIdleCallbackPolyfill,
2021
} = require('ReactFeatureFlags');
2122

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

0 commit comments

Comments
 (0)