Add feature flag to disable scheduler timeout in work loop (#19771)

This commit is contained in:
Ricky 2020-09-04 10:58:17 -04:00 committed by GitHub
parent eabd18c73f
commit 36df483af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 39 additions and 2 deletions

View File

@ -30,6 +30,7 @@ import {
enableSchedulingProfiler,
enableScopeAPI,
skipUnmountedBoundaries,
disableSchedulerTimeoutInWorkLoop,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
@ -750,7 +751,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
// This is the entry point for every concurrent task, i.e. anything that
// goes through Scheduler.
function performConcurrentWorkOnRoot(root) {
function performConcurrentWorkOnRoot(root, didTimeout) {
// Since we know we're in a React event, we can clear the current
// event time. The next update will compute a new event time.
currentEventTime = NoTimestamp;
@ -790,6 +791,18 @@ function performConcurrentWorkOnRoot(root) {
return null;
}
// TODO: We only check `didTimeout` defensively, to account for a Scheduler
// bug we're still investigating. Once the bug in Scheduler is fixed,
// we can remove this, since we track expiration ourselves.
if (!disableSchedulerTimeoutInWorkLoop && didTimeout) {
// Something expired. Flush synchronously until there's no expired
// work left.
markRootExpired(root, lanes);
// This will schedule a synchronous callback.
ensureRootIsScheduled(root, now());
return null;
}
let exitStatus = renderRootConcurrent(root, lanes);
if (

View File

@ -30,6 +30,7 @@ import {
enableSchedulingProfiler,
enableScopeAPI,
skipUnmountedBoundaries,
disableSchedulerTimeoutInWorkLoop,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
@ -738,7 +739,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
// This is the entry point for every concurrent task, i.e. anything that
// goes through Scheduler.
function performConcurrentWorkOnRoot(root) {
function performConcurrentWorkOnRoot(root, didTimeout) {
// Since we know we're in a React event, we can clear the current
// event time. The next update will compute a new event time.
currentEventTime = NoTimestamp;
@ -778,6 +779,18 @@ function performConcurrentWorkOnRoot(root) {
return null;
}
// TODO: We only check `didTimeout` defensively, to account for a Scheduler
// bug we're still investigating. Once the bug in Scheduler is fixed,
// we can remove this, since we track expiration ourselves.
if (!disableSchedulerTimeoutInWorkLoop && didTimeout) {
// Something expired. Flush synchronously until there's no expired
// work left.
markRootExpired(root, lanes);
// This will schedule a synchronous callback.
ensureRootIsScheduled(root, now());
return null;
}
let exitStatus = renderRootConcurrent(root, lanes);
if (

View File

@ -137,3 +137,5 @@ export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;

View File

@ -51,6 +51,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = false;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false;
export const enableDiscreteEventFlushingChange = true;
export const enablePassiveEventIntervention = true;
export const enableEagerRootListeners = true;
export const disableSchedulerTimeoutInWorkLoop = false;
// Flow magic to verify the exports of this file match the original version.
// eslint-disable-next-line no-unused-vars

View File

@ -48,3 +48,4 @@ export const replayFailedUnitOfWorkWithInvokeGuardedCallback = __DEV__;
// to __VARIANT__.
export const enableTrustedTypesIntegration = false;
export const disableSchedulerTimeoutBasedOnReactExpirationTime = false;
export const disableSchedulerTimeoutInWorkLoop = __VARIANT__;

View File

@ -29,6 +29,7 @@ export const {
skipUnmountedBoundaries,
enablePassiveEventIntervention,
enableEagerRootListeners,
disableSchedulerTimeoutInWorkLoop,
} = dynamicFeatureFlags;
// On WWW, __EXPERIMENTAL__ is used for a new modern build.