Skip to content

Commit

Permalink
Add feature flags for scheduler experiments (#22105)
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii authored Aug 24, 2021
1 parent edfe505 commit b0b53ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions packages/scheduler/src/SchedulerFeatureFlags.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@
export const enableSchedulerDebugging = false;
export const enableIsInputPending = false;
export const enableProfiling = false;
export const enableIsInputPendingContinuous = false;
export const frameYieldMs = 5;
export const continuousYieldMs = 50;
15 changes: 8 additions & 7 deletions packages/scheduler/src/forks/Scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
import {
enableSchedulerDebugging,
enableProfiling,
enableIsInputPending,
enableIsInputPendingContinuous,
frameYieldMs,
continuousYieldMs,
} from '../SchedulerFeatureFlags';

import {push, pop, peek} from '../SchedulerMinHeap';
Expand All @@ -36,8 +40,6 @@ import {
startLoggingProfilingEvents,
} from '../SchedulerProfiling';

import {enableIsInputPending} from '../SchedulerFeatureFlags';

let getCurrentTime;
const hasPerformanceNow =
typeof performance === 'object' && typeof performance.now === 'function';
Expand Down Expand Up @@ -98,7 +100,7 @@ const isInputPending =
? navigator.scheduling.isInputPending.bind(navigator.scheduling)
: null;

const continuousOptions = {includeContinuous: true};
const continuousOptions = {includeContinuous: enableIsInputPendingContinuous};

function advanceTimers(currentTime) {
// Check for tasks that are no longer delayed and add them to the queue.
Expand Down Expand Up @@ -427,9 +429,8 @@ let taskTimeoutID = -1;
// thread, like user events. By default, it yields multiple times per frame.
// It does not attempt to align with frame boundaries, since most tasks don't
// need to be frame aligned; for those that do, use requestAnimationFrame.
// TODO: Make these configurable
let frameInterval = 5;
const continuousInputInterval = 50;
let frameInterval = frameYieldMs;
const continuousInputInterval = continuousYieldMs;
const maxInterval = 300;
let startTime = -1;

Expand Down Expand Up @@ -506,7 +507,7 @@ function forceFrameRate(fps) {
frameInterval = Math.floor(1000 / fps);
} else {
// reset the framerate
frameInterval = 5;
frameInterval = frameYieldMs;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@
export const enableIsInputPending = __VARIANT__;
export const enableSchedulerDebugging = __VARIANT__;
export const enableProfiling = __VARIANT__;
export const enableIsInputPendingContinuous = __VARIANT__;
export const frameYieldMs = 5;
export const continuousYieldMs = 50;
3 changes: 3 additions & 0 deletions packages/scheduler/src/forks/SchedulerFeatureFlags.www.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const {
enableIsInputPending,
enableSchedulerDebugging,
enableProfiling: enableProfilingFeatureFlag,
enableIsInputPendingContinuous,
frameYieldMs,
continuousYieldMs,
} = dynamicFeatureFlags;

export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;

0 comments on commit b0b53ae

Please sign in to comment.