Skip to content

Commit

Permalink
Add back disableSchedulerTimeoutInWorkLoop flag (facebook#20482)
Browse files Browse the repository at this point in the history
* Add back enableSchedulerTimeoutInWorkLoop flag

* Nvm, keep it as disableSchedulerTimeoutInWorkLoop
  • Loading branch information
rickhanlonii authored and acdlite committed Jan 13, 2021
1 parent 5e0dfb9 commit d46de90
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 14 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
enableDebugTracing,
enableSchedulingProfiler,
enableScopeAPI,
disableSchedulerTimeoutInWorkLoop,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -767,7 +768,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) {
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
resetNestedUpdateFlag();
}
Expand Down Expand Up @@ -811,6 +812,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 (
Expand Down
15 changes: 14 additions & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
enableSchedulingProfiler,
enableScopeAPI,
enableDoubleInvokingEffects,
disableSchedulerTimeoutInWorkLoop,
} from 'shared/ReactFeatureFlags';
import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down Expand Up @@ -775,7 +776,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) {
if (enableProfilerTimer && enableProfilerNestedUpdatePhase) {
resetNestedUpdateFlag();
}
Expand Down Expand Up @@ -819,6 +820,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 (
Expand Down

0 comments on commit d46de90

Please sign in to comment.