From b0b53ae2c1f38a7bf82b537dafb5f60f1bf14d0d Mon Sep 17 00:00:00 2001 From: Ricky Date: Tue, 24 Aug 2021 12:47:51 -0400 Subject: [PATCH] Add feature flags for scheduler experiments (#22105) --- packages/scheduler/src/SchedulerFeatureFlags.js | 3 +++ packages/scheduler/src/forks/Scheduler.js | 15 ++++++++------- .../forks/SchedulerFeatureFlags.www-dynamic.js | 3 +++ .../src/forks/SchedulerFeatureFlags.www.js | 3 +++ 4 files changed, 17 insertions(+), 7 deletions(-) diff --git a/packages/scheduler/src/SchedulerFeatureFlags.js b/packages/scheduler/src/SchedulerFeatureFlags.js index 9b9deeb63ec1..0e82d57d34f1 100644 --- a/packages/scheduler/src/SchedulerFeatureFlags.js +++ b/packages/scheduler/src/SchedulerFeatureFlags.js @@ -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; diff --git a/packages/scheduler/src/forks/Scheduler.js b/packages/scheduler/src/forks/Scheduler.js index 2ffa20688bc4..5cddcaae927e 100644 --- a/packages/scheduler/src/forks/Scheduler.js +++ b/packages/scheduler/src/forks/Scheduler.js @@ -11,6 +11,10 @@ import { enableSchedulerDebugging, enableProfiling, + enableIsInputPending, + enableIsInputPendingContinuous, + frameYieldMs, + continuousYieldMs, } from '../SchedulerFeatureFlags'; import {push, pop, peek} from '../SchedulerMinHeap'; @@ -36,8 +40,6 @@ import { startLoggingProfilingEvents, } from '../SchedulerProfiling'; -import {enableIsInputPending} from '../SchedulerFeatureFlags'; - let getCurrentTime; const hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; @@ -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. @@ -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; @@ -506,7 +507,7 @@ function forceFrameRate(fps) { frameInterval = Math.floor(1000 / fps); } else { // reset the framerate - frameInterval = 5; + frameInterval = frameYieldMs; } } diff --git a/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js b/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js index 086762d7b707..9615918d127d 100644 --- a/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js +++ b/packages/scheduler/src/forks/SchedulerFeatureFlags.www-dynamic.js @@ -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; diff --git a/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js b/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js index 9087af8b22f7..00e9b0ff6557 100644 --- a/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js +++ b/packages/scheduler/src/forks/SchedulerFeatureFlags.www.js @@ -13,6 +13,9 @@ export const { enableIsInputPending, enableSchedulerDebugging, enableProfiling: enableProfilingFeatureFlag, + enableIsInputPendingContinuous, + frameYieldMs, + continuousYieldMs, } = dynamicFeatureFlags; export const enableProfiling = __PROFILE__ && enableProfilingFeatureFlag;