GeezerVison is showing github.com — Add feature flag to disable scheduler timeout in work loop (#19771) · react/react@36df483
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.new.js +14-1Lines changed: 14 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ import { | 30 | 30 | enableSchedulingProfiler, | 31 | 31 | enableScopeAPI, | 32 | 32 | skipUnmountedBoundaries, | | 33 | + disableSchedulerTimeoutInWorkLoop, | 33 | 34 | } from 'shared/ReactFeatureFlags'; | 34 | 35 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 35 | 36 | import invariant from 'shared/invariant'; | @@ -750,7 +751,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 750 | 751 |
| 751 | 752 | // This is the entry point for every concurrent task, i.e. anything that | 752 | 753 | // goes through Scheduler. | 753 | | -function performConcurrentWorkOnRoot(root) { | | 754 | +function performConcurrentWorkOnRoot(root, didTimeout) { | 754 | 755 | // Since we know we're in a React event, we can clear the current | 755 | 756 | // event time. The next update will compute a new event time. | 756 | 757 | currentEventTime = NoTimestamp; | @@ -790,6 +791,18 @@ function performConcurrentWorkOnRoot(root) { | 790 | 791 | return null; | 791 | 792 | } | 792 | 793 |
| | 794 | + // TODO: We only check `didTimeout` defensively, to account for a Scheduler | | 795 | + // bug we're still investigating. Once the bug in Scheduler is fixed, | | 796 | + // we can remove this, since we track expiration ourselves. | | 797 | + if (!disableSchedulerTimeoutInWorkLoop && didTimeout) { | | 798 | + // Something expired. Flush synchronously until there's no expired | | 799 | + // work left. | | 800 | + markRootExpired(root, lanes); | | 801 | + // This will schedule a synchronous callback. | | 802 | + ensureRootIsScheduled(root, now()); | | 803 | + return null; | | 804 | + } | | 805 | + | 793 | 806 | let exitStatus = renderRootConcurrent(root, lanes); | 794 | 807 |
| 795 | 808 | if ( | |
Collapse file Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberWorkLoop.old.js +14-1Lines changed: 14 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -30,6 +30,7 @@ import { | 30 | 30 | enableSchedulingProfiler, | 31 | 31 | enableScopeAPI, | 32 | 32 | skipUnmountedBoundaries, | | 33 | + disableSchedulerTimeoutInWorkLoop, | 33 | 34 | } from 'shared/ReactFeatureFlags'; | 34 | 35 | import ReactSharedInternals from 'shared/ReactSharedInternals'; | 35 | 36 | import invariant from 'shared/invariant'; | @@ -738,7 +739,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) { | 738 | 739 |
| 739 | 740 | // This is the entry point for every concurrent task, i.e. anything that | 740 | 741 | // goes through Scheduler. | 741 | | -function performConcurrentWorkOnRoot(root) { | | 742 | +function performConcurrentWorkOnRoot(root, didTimeout) { | 742 | 743 | // Since we know we're in a React event, we can clear the current | 743 | 744 | // event time. The next update will compute a new event time. | 744 | 745 | currentEventTime = NoTimestamp; | @@ -778,6 +779,18 @@ function performConcurrentWorkOnRoot(root) { | 778 | 779 | return null; | 779 | 780 | } | 780 | 781 |
| | 782 | + // TODO: We only check `didTimeout` defensively, to account for a Scheduler | | 783 | + // bug we're still investigating. Once the bug in Scheduler is fixed, | | 784 | + // we can remove this, since we track expiration ourselves. | | 785 | + if (!disableSchedulerTimeoutInWorkLoop && didTimeout) { | | 786 | + // Something expired. Flush synchronously until there's no expired | | 787 | + // work left. | | 788 | + markRootExpired(root, lanes); | | 789 | + // This will schedule a synchronous callback. | | 790 | + ensureRootIsScheduled(root, now()); | | 791 | + return null; | | 792 | + } | | 793 | + | 781 | 794 | let exitStatus = renderRootConcurrent(root, lanes); | 782 | 795 |
| 783 | 796 | if ( | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/ReactFeatureFlags.js +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -137,3 +137,5 @@ export const enableDiscreteEventFlushingChange = false; | 137 | 137 | export const enablePassiveEventIntervention = true; | 138 | 138 |
| 139 | 139 | export const enableEagerRootListeners = true; | | 140 | + | | 141 | +export const disableSchedulerTimeoutInWorkLoop = false; |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-fb.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -51,6 +51,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 51 | 51 | export const enableDiscreteEventFlushingChange = false; | 52 | 52 | export const enablePassiveEventIntervention = true; | 53 | 53 | export const enableEagerRootListeners = true; | | 54 | +export const disableSchedulerTimeoutInWorkLoop = false; | 54 | 55 |
| 55 | 56 | // Flow magic to verify the exports of this file match the original version. | 56 | 57 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.native-oss.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.native.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.test-renderer.www.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.testing.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = false; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
Collapse file Copy file name to clipboardExpand all lines: packages/shared/forks/ReactFeatureFlags.testing.www.js +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,6 +50,7 @@ export const decoupleUpdatePriorityFromScheduler = false; | 50 | 50 | export const enableDiscreteEventFlushingChange = true; | 51 | 51 | export const enablePassiveEventIntervention = true; | 52 | 52 | export const enableEagerRootListeners = true; | | 53 | +export const disableSchedulerTimeoutInWorkLoop = false; | 53 | 54 |
| 54 | 55 | // Flow magic to verify the exports of this file match the original version. | 55 | 56 | // eslint-disable-next-line no-unused-vars | |
|