Skip to content

Commit 3460c79

Browse files
committed
Add feature flags for scheduler experiments
1 parent f6ec466 commit 3460c79

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

packages/scheduler/src/SchedulerFeatureFlags.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,6 @@
88

99
export const enableSchedulerDebugging = false;
1010
export const enableIsInputPending = false;
11+
export const enableIsInputPendingContinuous = false;
1112
export const enableProfiling = __VARIANT__;
13+
export const schedulerYieldMs = 5;

packages/scheduler/src/forks/Scheduler.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
import {
1212
enableSchedulerDebugging,
1313
enableProfiling,
14+
enableIsInputPending,
15+
enableIsInputPendingContinuous,
16+
schedulerYieldMs,
1417
} from '../SchedulerFeatureFlags';
1518

1619
import {push, pop, peek} from '../SchedulerMinHeap';
@@ -36,8 +39,6 @@ import {
3639
startLoggingProfilingEvents,
3740
} from '../SchedulerProfiling';
3841

39-
import {enableIsInputPending} from '../SchedulerFeatureFlags';
40-
4142
let getCurrentTime;
4243
const hasPerformanceNow =
4344
typeof performance === 'object' && typeof performance.now === 'function';
@@ -418,7 +419,7 @@ let taskTimeoutID = -1;
418419
// thread, like user events. By default, it yields multiple times per frame.
419420
// It does not attempt to align with frame boundaries, since most tasks don't
420421
// need to be frame aligned; for those that do, use requestAnimationFrame.
421-
let yieldInterval = 5;
422+
let yieldInterval = schedulerYieldMs;
422423
let deadline = 0;
423424

424425
// TODO: Make this configurable
@@ -444,7 +445,12 @@ function shouldYieldToHost() {
444445
// regardless, since there could be a pending paint that wasn't
445446
// accompanied by a call to `requestPaint`, or other main thread tasks
446447
// like network events.
447-
if (needsPaint || scheduling.isInputPending()) {
448+
if (
449+
needsPaint ||
450+
scheduling.isInputPending({
451+
includeContinuous: enableIsInputPendingContinuous,
452+
})
453+
) {
448454
// There is either a pending paint or a pending input.
449455
return true;
450456
}
@@ -489,7 +495,7 @@ function forceFrameRate(fps) {
489495
yieldInterval = Math.floor(1000 / fps);
490496
} else {
491497
// reset the framerate
492-
yieldInterval = 5;
498+
yieldInterval = schedulerYieldMs;
493499
}
494500
}
495501

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88

99
export const {
1010
enableIsInputPending,
11+
enableIsInputPendingContinuous,
1112
enableSchedulerDebugging,
1213
enableProfiling: enableProfilingFeatureFlag,
14+
schedulerYieldMs,
1315
} = require('SchedulerFeatureFlags');
1416

1517
export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;

0 commit comments

Comments
 (0)