Skip to content

Commit b8a5408

Browse files
authored
Revert "Make time-slicing opt-in (facebook#21072)"
This reverts commit 933880b.
1 parent 9d48779 commit b8a5408

File tree

46 files changed

+538
-1996
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+538
-1996
lines changed

packages/create-subscription/src/__tests__/createSubscription-test.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,6 @@ describe('createSubscription', () => {
268268
expect(Scheduler).toFlushAndYield(['b-1']);
269269
});
270270

271-
// @gate experimental || !enableSyncDefaultUpdates
272271
it('should ignore values emitted by a new subscribable until the commit phase', () => {
273272
const log = [];
274273

@@ -326,13 +325,7 @@ describe('createSubscription', () => {
326325
expect(log).toEqual(['Parent.componentDidMount']);
327326

328327
// Start React update, but don't finish
329-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
330-
React.unstable_startTransition(() => {
331-
ReactNoop.render(<Parent observed={observableB} />);
332-
});
333-
} else {
334-
ReactNoop.render(<Parent observed={observableB} />);
335-
}
328+
ReactNoop.render(<Parent observed={observableB} />);
336329
expect(Scheduler).toFlushAndYieldThrough(['Subscriber: b-0']);
337330
expect(log).toEqual(['Parent.componentDidMount']);
338331

@@ -362,7 +355,6 @@ describe('createSubscription', () => {
362355
]);
363356
});
364357

365-
// @gate experimental || !enableSyncDefaultUpdates
366358
it('should not drop values emitted between updates', () => {
367359
const log = [];
368360

@@ -420,13 +412,7 @@ describe('createSubscription', () => {
420412
expect(log).toEqual(['Parent.componentDidMount']);
421413

422414
// Start React update, but don't finish
423-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
424-
React.unstable_startTransition(() => {
425-
ReactNoop.render(<Parent observed={observableB} />);
426-
});
427-
} else {
428-
ReactNoop.render(<Parent observed={observableB} />);
429-
}
415+
ReactNoop.render(<Parent observed={observableB} />);
430416
expect(Scheduler).toFlushAndYieldThrough(['Subscriber: b-0']);
431417
expect(log).toEqual(['Parent.componentDidMount']);
432418

packages/react-art/src/__tests__/ReactART-test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ describe('ReactART', () => {
360360
expect(onClick2).toBeCalled();
361361
});
362362

363-
// @gate !enableSyncDefaultUpdates
364363
it('can concurrently render with a "primary" renderer while sharing context', () => {
365364
const CurrentRendererContext = React.createContext(null);
366365

packages/react-dom/src/__tests__/ReactDOMNativeEventHeuristic-test.js

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -284,46 +284,6 @@ describe('ReactDOMNativeEventHeuristic-test', () => {
284284
expect(container.textContent).toEqual('hovered');
285285
});
286286

287-
// @gate experimental
288-
it('continuous native events flush as expected', async () => {
289-
const root = ReactDOM.unstable_createRoot(container);
290-
291-
const target = React.createRef(null);
292-
function Foo({hovered}) {
293-
const hoverString = hovered ? 'hovered' : 'not hovered';
294-
Scheduler.unstable_yieldValue(hoverString);
295-
return <div ref={target}>{hoverString}</div>;
296-
}
297-
298-
await act(async () => {
299-
root.render(<Foo hovered={false} />);
300-
});
301-
expect(container.textContent).toEqual('not hovered');
302-
303-
await act(async () => {
304-
// Note: React does not use native mouseenter/mouseleave events
305-
// but we should still correctly determine their priority.
306-
const mouseEnterEvent = document.createEvent('MouseEvents');
307-
mouseEnterEvent.initEvent('mouseover', true, true);
308-
target.current.addEventListener('mouseover', () => {
309-
root.render(<Foo hovered={true} />);
310-
});
311-
dispatchAndSetCurrentEvent(target.current, mouseEnterEvent);
312-
313-
// Since mouse end is not discrete, should not have updated yet
314-
expect(Scheduler).toHaveYielded(['not hovered']);
315-
expect(container.textContent).toEqual('not hovered');
316-
317-
expect(Scheduler).toFlushAndYieldThrough(['hovered']);
318-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
319-
expect(container.textContent).toEqual('hovered');
320-
} else {
321-
expect(container.textContent).toEqual('not hovered');
322-
}
323-
});
324-
expect(container.textContent).toEqual('hovered');
325-
});
326-
327287
// @gate experimental
328288
it('should batch inside native events', async () => {
329289
const root = ReactDOM.unstable_createRoot(container);

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,21 +1865,11 @@ describe('ReactDOMServerPartialHydration', () => {
18651865
suspend = true;
18661866

18671867
await act(async () => {
1868-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1869-
React.unstable_startTransition(() => {
1870-
root.render(<App />);
1871-
});
1872-
1873-
expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']);
1874-
} else {
1875-
root.render(<App />);
1876-
1877-
expect(Scheduler).toFlushAndYieldThrough(['Before']);
1878-
// This took a long time to render.
1879-
Scheduler.unstable_advanceTime(1000);
1880-
expect(Scheduler).toFlushAndYield(['After']);
1881-
}
1882-
1868+
root.render(<App />);
1869+
expect(Scheduler).toFlushAndYieldThrough(['Before']);
1870+
// This took a long time to render.
1871+
Scheduler.unstable_advanceTime(1000);
1872+
expect(Scheduler).toFlushAndYield(['After']);
18831873
// This will cause us to skip the second row completely.
18841874
});
18851875

packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1934,13 +1934,7 @@ describe('DOMPluginEventSystem', () => {
19341934
log.length = 0;
19351935

19361936
// Increase counter
1937-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1938-
React.unstable_startTransition(() => {
1939-
root.render(<Test counter={1} />);
1940-
});
1941-
} else {
1942-
root.render(<Test counter={1} />);
1943-
}
1937+
root.render(<Test counter={1} />);
19441938
// Yield before committing
19451939
expect(Scheduler).toFlushAndYieldThrough(['Test']);
19461940

packages/react-reconciler/src/ReactFiberLane.new.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const NoLane: Lane = /* */ 0b0000000000000000000
5252

5353
export const SyncLane: Lane = /* */ 0b0000000000000000000000000000001;
5454

55-
export const InputContinuousHydrationLane: Lane = /* */ 0b0000000000000000000000000000010;
55+
const InputContinuousHydrationLane: Lane = /* */ 0b0000000000000000000000000000010;
5656
export const InputContinuousLane: Lanes = /* */ 0b0000000000000000000000000000100;
5757

5858
export const DefaultHydrationLane: Lane = /* */ 0b0000000000000000000000000001000;

packages/react-reconciler/src/ReactFiberLane.old.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const NoLane: Lane = /* */ 0b0000000000000000000
5252

5353
export const SyncLane: Lane = /* */ 0b0000000000000000000000000000001;
5454

55-
export const InputContinuousHydrationLane: Lane = /* */ 0b0000000000000000000000000000010;
55+
const InputContinuousHydrationLane: Lane = /* */ 0b0000000000000000000000000000010;
5656
export const InputContinuousLane: Lanes = /* */ 0b0000000000000000000000000000100;
5757

5858
export const DefaultHydrationLane: Lane = /* */ 0b0000000000000000000000000001000;

packages/react-reconciler/src/ReactFiberWorkLoop.new.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
disableSchedulerTimeoutInWorkLoop,
3333
enableStrictEffects,
3434
skipUnmountedBoundaries,
35-
enableSyncDefaultUpdates,
3635
enableUpdaterTracking,
3736
} from 'shared/ReactFeatureFlags';
3837
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -139,10 +138,6 @@ import {
139138
NoLanes,
140139
NoLane,
141140
SyncLane,
142-
DefaultLane,
143-
DefaultHydrationLane,
144-
InputContinuousLane,
145-
InputContinuousHydrationLane,
146141
NoTimestamp,
147142
claimNextTransitionLane,
148143
claimNextRetryLane,
@@ -438,13 +433,6 @@ export function requestUpdateLane(fiber: Fiber): Lane {
438433
// TODO: Move this type conversion to the event priority module.
439434
const updateLane: Lane = (getCurrentUpdatePriority(): any);
440435
if (updateLane !== NoLane) {
441-
if (
442-
enableSyncDefaultUpdates &&
443-
(updateLane === InputContinuousLane ||
444-
updateLane === InputContinuousHydrationLane)
445-
) {
446-
return DefaultLane;
447-
}
448436
return updateLane;
449437
}
450438

@@ -455,13 +443,6 @@ export function requestUpdateLane(fiber: Fiber): Lane {
455443
// use that directly.
456444
// TODO: Move this type conversion to the event priority module.
457445
const eventLane: Lane = (getCurrentEventPriority(): any);
458-
if (
459-
enableSyncDefaultUpdates &&
460-
(eventLane === InputContinuousLane ||
461-
eventLane === InputContinuousHydrationLane)
462-
) {
463-
return DefaultLane;
464-
}
465446
return eventLane;
466447
}
467448

@@ -714,16 +695,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
714695

715696
// Schedule a new callback.
716697
let newCallbackNode;
717-
if (
718-
enableSyncDefaultUpdates &&
719-
(newCallbackPriority === DefaultLane ||
720-
newCallbackPriority === DefaultHydrationLane)
721-
) {
722-
newCallbackNode = scheduleCallback(
723-
ImmediateSchedulerPriority,
724-
performSyncWorkOnRoot.bind(null, root),
725-
);
726-
} else if (newCallbackPriority === SyncLane) {
698+
if (newCallbackPriority === SyncLane) {
727699
// Special case: Sync React callbacks are scheduled on a special
728700
// internal queue
729701
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
@@ -1058,11 +1030,7 @@ function performSyncWorkOnRoot(root) {
10581030
const finishedWork: Fiber = (root.current.alternate: any);
10591031
root.finishedWork = finishedWork;
10601032
root.finishedLanes = lanes;
1061-
if (enableSyncDefaultUpdates && !includesSomeLane(lanes, SyncLane)) {
1062-
finishConcurrentRender(root, exitStatus, lanes);
1063-
} else {
1064-
commitRoot(root);
1065-
}
1033+
commitRoot(root);
10661034

10671035
// Before exiting, make sure there's a callback scheduled for the next
10681036
// pending level.

packages/react-reconciler/src/ReactFiberWorkLoop.old.js

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
disableSchedulerTimeoutInWorkLoop,
3333
enableStrictEffects,
3434
skipUnmountedBoundaries,
35-
enableSyncDefaultUpdates,
3635
enableUpdaterTracking,
3736
} from 'shared/ReactFeatureFlags';
3837
import ReactSharedInternals from 'shared/ReactSharedInternals';
@@ -139,10 +138,6 @@ import {
139138
NoLanes,
140139
NoLane,
141140
SyncLane,
142-
DefaultLane,
143-
DefaultHydrationLane,
144-
InputContinuousLane,
145-
InputContinuousHydrationLane,
146141
NoTimestamp,
147142
claimNextTransitionLane,
148143
claimNextRetryLane,
@@ -438,13 +433,6 @@ export function requestUpdateLane(fiber: Fiber): Lane {
438433
// TODO: Move this type conversion to the event priority module.
439434
const updateLane: Lane = (getCurrentUpdatePriority(): any);
440435
if (updateLane !== NoLane) {
441-
if (
442-
enableSyncDefaultUpdates &&
443-
(updateLane === InputContinuousLane ||
444-
updateLane === InputContinuousHydrationLane)
445-
) {
446-
return DefaultLane;
447-
}
448436
return updateLane;
449437
}
450438

@@ -455,13 +443,6 @@ export function requestUpdateLane(fiber: Fiber): Lane {
455443
// use that directly.
456444
// TODO: Move this type conversion to the event priority module.
457445
const eventLane: Lane = (getCurrentEventPriority(): any);
458-
if (
459-
enableSyncDefaultUpdates &&
460-
(eventLane === InputContinuousLane ||
461-
eventLane === InputContinuousHydrationLane)
462-
) {
463-
return DefaultLane;
464-
}
465446
return eventLane;
466447
}
467448

@@ -714,16 +695,7 @@ function ensureRootIsScheduled(root: FiberRoot, currentTime: number) {
714695

715696
// Schedule a new callback.
716697
let newCallbackNode;
717-
if (
718-
enableSyncDefaultUpdates &&
719-
(newCallbackPriority === DefaultLane ||
720-
newCallbackPriority === DefaultHydrationLane)
721-
) {
722-
newCallbackNode = scheduleCallback(
723-
ImmediateSchedulerPriority,
724-
performSyncWorkOnRoot.bind(null, root),
725-
);
726-
} else if (newCallbackPriority === SyncLane) {
698+
if (newCallbackPriority === SyncLane) {
727699
// Special case: Sync React callbacks are scheduled on a special
728700
// internal queue
729701
scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root));
@@ -1058,11 +1030,7 @@ function performSyncWorkOnRoot(root) {
10581030
const finishedWork: Fiber = (root.current.alternate: any);
10591031
root.finishedWork = finishedWork;
10601032
root.finishedLanes = lanes;
1061-
if (enableSyncDefaultUpdates && !includesSomeLane(lanes, SyncLane)) {
1062-
finishConcurrentRender(root, exitStatus, lanes);
1063-
} else {
1064-
commitRoot(root);
1065-
}
1033+
commitRoot(root);
10661034

10671035
// Before exiting, make sure there's a callback scheduled for the next
10681036
// pending level.

packages/react-reconciler/src/__tests__/ReactDisableSchedulerTimeoutBasedOnReactExpirationTime-test.internal.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ describe('ReactSuspenseList', () => {
4545
return Component;
4646
}
4747

48-
// @gate experimental || !enableSyncDefaultUpdates
4948
it('appends rendering tasks to the end of the priority queue', async () => {
5049
const A = createAsyncText('A');
5150
const B = createAsyncText('B');
@@ -64,13 +63,7 @@ describe('ReactSuspenseList', () => {
6463
root.render(<App show={false} />);
6564
expect(Scheduler).toFlushAndYield([]);
6665

67-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
68-
React.unstable_startTransition(() => {
69-
root.render(<App show={true} />);
70-
});
71-
} else {
72-
root.render(<App show={true} />);
73-
}
66+
root.render(<App show={true} />);
7467
expect(Scheduler).toFlushAndYield([
7568
'Suspend! [A]',
7669
'Suspend! [B]',

0 commit comments

Comments
 (0)