@samitouri / QOS-React-2 / commits / b0b53ae2c1

Add feature flags for scheduler experiments (#22105)

Ricky committed Aug 24, 2021 at 12:47 UTC b0b53ae2c1f38a7bf82b537dafb5f60f1bf14d0d
4 files changed +17 -7
packages/scheduler/src/SchedulerFeatureFlags.js
+3
@@ -9,3 +9,6 @@
9 export const enableSchedulerDebugging = false;
10 export const enableIsInputPending = false;
11 export const enableProfiling = false;
12 +export const enableIsInputPendingContinuous = false;
13 +export const frameYieldMs = 5;
14 +export const continuousYieldMs = 50;
packages/scheduler/src/forks/Scheduler.js
+8 -7
@@ -11,6 +11,10 @@
11 import {
12 enableSchedulerDebugging,
13 enableProfiling,
14 + enableIsInputPending,
15 + enableIsInputPendingContinuous,
16 + frameYieldMs,
17 + continuousYieldMs,
18 } from '../SchedulerFeatureFlags';
19
20 import {push, pop, peek} from '../SchedulerMinHeap';
@@ -36,8 +40,6 @@ import {
40 startLoggingProfilingEvents,
41 } from '../SchedulerProfiling';
42
39 -import {enableIsInputPending} from '../SchedulerFeatureFlags';
40 -
43 let getCurrentTime;
44 const hasPerformanceNow =
45 typeof performance === 'object' && typeof performance.now === 'function';
@@ -98,7 +100,7 @@ const isInputPending =
100 ? navigator.scheduling.isInputPending.bind(navigator.scheduling)
101 : null;
102
101 -const continuousOptions = {includeContinuous: true};
103 +const continuousOptions = {includeContinuous: enableIsInputPendingContinuous};
104
105 function advanceTimers(currentTime) {
106 // Check for tasks that are no longer delayed and add them to the queue.
@@ -427,9 +429,8 @@ let taskTimeoutID = -1;
429 // thread, like user events. By default, it yields multiple times per frame.
430 // It does not attempt to align with frame boundaries, since most tasks don't
431 // need to be frame aligned; for those that do, use requestAnimationFrame.
430 -// TODO: Make these configurable
431 -let frameInterval = 5;
432 -const continuousInputInterval = 50;
432 +let frameInterval = frameYieldMs;
433 +const continuousInputInterval = continuousYieldMs;
434 const maxInterval = 300;
435 let startTime = -1;
436
@@ -506,7 +507,7 @@ function forceFrameRate(fps) {
507 frameInterval = Math.floor(1000 / fps);
508 } else {
509 // reset the framerate
509 - frameInterval = 5;
510 + frameInterval = frameYieldMs;
511 }
512 }
513
packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js
+3
@@ -15,3 +15,6 @@
15 export const enableIsInputPending = __VARIANT__;
16 export const enableSchedulerDebugging = __VARIANT__;
17 export const enableProfiling = __VARIANT__;
18 +export const enableIsInputPendingContinuous = __VARIANT__;
19 +export const frameYieldMs = 5;
20 +export const continuousYieldMs = 50;
packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
+3
@@ -13,6 +13,9 @@ export const {
13 enableIsInputPending,
14 enableSchedulerDebugging,
15 enableProfiling: enableProfilingFeatureFlag,
16 + enableIsInputPendingContinuous,
17 + frameYieldMs,
18 + continuousYieldMs,
19 } = dynamicFeatureFlags;
20
21 export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;