Skip to content

Commit fd9f19a

Browse files
rickhanloniizhengjitf
authored andcommitted
Add feature flags for scheduler experiments (facebook#22105)
1 parent 6802821 commit fd9f19a

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

packages/scheduler/src/SchedulerFeatureFlags.js

+3
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
export const enableSchedulerDebugging = false;
1010
export const enableIsInputPending = false;
1111
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
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
import {
1212
enableSchedulerDebugging,
1313
enableProfiling,
14+
enableIsInputPending,
15+
enableIsInputPendingContinuous,
16+
frameYieldMs,
17+
continuousYieldMs,
1418
} from '../SchedulerFeatureFlags';
1519

1620
import {push, pop, peek} from '../SchedulerMinHeap';
@@ -36,8 +40,6 @@ import {
3640
startLoggingProfilingEvents,
3741
} from '../SchedulerProfiling';
3842

39-
import {enableIsInputPending} from '../SchedulerFeatureFlags';
40-
4143
let getCurrentTime;
4244
const hasPerformanceNow =
4345
typeof performance === 'object' && typeof performance.now === 'function';
@@ -98,7 +100,7 @@ const isInputPending =
98100
? navigator.scheduling.isInputPending.bind(navigator.scheduling)
99101
: null;
100102

101-
const continuousOptions = {includeContinuous: true};
103+
const continuousOptions = {includeContinuous: enableIsInputPendingContinuous};
102104

103105
function advanceTimers(currentTime) {
104106
// Check for tasks that are no longer delayed and add them to the queue.
@@ -427,9 +429,8 @@ let taskTimeoutID = -1;
427429
// thread, like user events. By default, it yields multiple times per frame.
428430
// It does not attempt to align with frame boundaries, since most tasks don't
429431
// 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;
433434
const maxInterval = 300;
434435
let startTime = -1;
435436

@@ -506,7 +507,7 @@ function forceFrameRate(fps) {
506507
frameInterval = Math.floor(1000 / fps);
507508
} else {
508509
// reset the framerate
509-
frameInterval = 5;
510+
frameInterval = frameYieldMs;
510511
}
511512
}
512513

packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@
1515
export const enableIsInputPending = __VARIANT__;
1616
export const enableSchedulerDebugging = __VARIANT__;
1717
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
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ export const {
1313
enableIsInputPending,
1414
enableSchedulerDebugging,
1515
enableProfiling: enableProfilingFeatureFlag,
16+
enableIsInputPendingContinuous,
17+
frameYieldMs,
18+
continuousYieldMs,
1619
} = dynamicFeatureFlags;
1720

1821
export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;

0 commit comments

Comments
 (0)