Skip to content

Commit

Permalink
Clean up enableUnifiedSyncLane flag (#30062)
Browse files Browse the repository at this point in the history
`enableUnifiedSyncLane` now passes everywhere. Let's clean it up

Implemented with #27646

Flag enabled with #27646,
#28269,
#29052
  • Loading branch information
jackpope committed Jun 24, 2024
1 parent 7608516 commit c21bcd6
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 276 deletions.
15 changes: 3 additions & 12 deletions packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,21 +313,12 @@ describe('ReactDOMFiberAsync', () => {
assertLog([]);
});
// Only the active updates have flushed
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(container.textContent).toEqual('ABC');
assertLog(['ABC']);
} else {
expect(container.textContent).toEqual('BC');
assertLog(['BC']);
}
expect(container.textContent).toEqual('ABC');
assertLog(['ABC']);

await act(() => {
instance.push('D');
if (gate(flags => flags.enableUnifiedSyncLane)) {
expect(container.textContent).toEqual('ABC');
} else {
expect(container.textContent).toEqual('BC');
}
expect(container.textContent).toEqual('ABC');
assertLog([]);
});
assertLog(['ABCD']);
Expand Down
16 changes: 6 additions & 10 deletions packages/react-reconciler/src/ReactFiberLane.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
enableRetryLaneExpiration,
enableSchedulingProfiler,
enableTransitionTracing,
enableUnifiedSyncLane,
enableUpdaterTracking,
syncLaneExpirationMs,
transitionLaneExpirationMs,
Expand Down Expand Up @@ -51,9 +50,8 @@ export const InputContinuousLane: Lane = /* */ 0b0000000000000000000
export const DefaultHydrationLane: Lane = /* */ 0b0000000000000000000000000010000;
export const DefaultLane: Lane = /* */ 0b0000000000000000000000000100000;

export const SyncUpdateLanes: Lane = enableUnifiedSyncLane
? SyncLane | InputContinuousLane | DefaultLane
: SyncLane;
export const SyncUpdateLanes: Lane =
SyncLane | InputContinuousLane | DefaultLane;

const TransitionHydrationLane: Lane = /* */ 0b0000000000000000000000001000000;
const TransitionLanes: Lanes = /* */ 0b0000000001111111111111110000000;
Expand Down Expand Up @@ -151,11 +149,9 @@ let nextTransitionLane: Lane = TransitionLane1;
let nextRetryLane: Lane = RetryLane1;

function getHighestPriorityLanes(lanes: Lanes | Lane): Lanes {
if (enableUnifiedSyncLane) {
const pendingSyncLanes = lanes & SyncUpdateLanes;
if (pendingSyncLanes !== 0) {
return pendingSyncLanes;
}
const pendingSyncLanes = lanes & SyncUpdateLanes;
if (pendingSyncLanes !== 0) {
return pendingSyncLanes;
}
switch (getHighestPriorityLane(lanes)) {
case SyncHydrationLane:
Expand Down Expand Up @@ -826,7 +822,7 @@ export function getBumpedLaneForHydration(
const renderLane = getHighestPriorityLane(renderLanes);

let lane;
if (enableUnifiedSyncLane && (renderLane & SyncUpdateLanes) !== NoLane) {
if ((renderLane & SyncUpdateLanes) !== NoLane) {
lane = SyncHydrationLane;
} else {
switch (renderLane) {
Expand Down
9 changes: 2 additions & 7 deletions packages/react-reconciler/src/__tests__/Activity-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,15 +698,10 @@ describe('Activity', () => {
);

// Before the inner update can finish, we receive another pair of updates.
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
setOuter(2);
setInner(2);
});
} else {
React.startTransition(() => {
setOuter(2);
setInner(2);
}
});

// Also, before either of these new updates are processed, the hidden
// tree is revealed at high priority.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,7 @@ describe('ReactBlockingMode', () => {
);

// Now flush the first update
if (gate(flags => flags.enableUnifiedSyncLane)) {
assertLog(['A1', 'B1']);
expect(root).toMatchRenderedOutput('A1B1');
} else {
// Only the second update should have flushed synchronously
assertLog(['B1']);
expect(root).toMatchRenderedOutput('A0B1');

// Now flush the first update
await waitForAll(['A1']);
expect(root).toMatchRenderedOutput('A1B1');
}
assertLog(['A1', 'B1']);
expect(root).toMatchRenderedOutput('A1B1');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,9 @@ describe('ReactClassSetStateCallback', () => {
assertLog([0]);

await act(() => {
if (gate(flags => flags.enableUnifiedSyncLane)) {
React.startTransition(() => {
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
});
} else {
React.startTransition(() => {
app.setState({step: 1}, () => Scheduler.log('Callback 1'));
}
});
ReactNoop.flushSync(() => {
app.setState({step: 2}, () => Scheduler.log('Callback 2'));
});
Expand Down
11 changes: 2 additions & 9 deletions packages/react-reconciler/src/__tests__/ReactFlushSync-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,13 @@ describe('ReactFlushSync', () => {

// The passive effect will schedule a sync update and a normal update.
// They should commit in two separate batches. First the sync one.
await waitForPaint(
gate(flags => flags.enableUnifiedSyncLane) ? ['1, 1'] : ['1, 0'],
);
await waitForPaint(['1, 1']);

// The remaining update is not sync
ReactDOM.flushSync();
assertLog([]);

if (gate(flags => flags.enableUnifiedSyncLane)) {
await waitForPaint([]);
} else {
// Now flush it.
await waitForPaint(['1, 1']);
}
await waitForPaint([]);
});
expect(getVisibleChildren(container)).toEqual('1, 1');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,8 @@ describe('ReactHooks', () => {
});
};

if (gate(flags => flags.enableUnifiedSyncLane)) {
// Update at transition priority
React.startTransition(() => update(n => n * 100));
} else {
// Update at normal priority
ReactTestRenderer.unstable_batchedUpdates(() => update(n => n * 100));
}
// Update at transition priority
React.startTransition(() => update(n => n * 100));
// The new state is eagerly computed.
assertLog(['Compute state (1 -> 100)']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -899,15 +899,8 @@ describe('ReactHooksWithNoopRenderer', () => {
ReactNoop.flushSync(() => {
counter.current.dispatch(INCREMENT);
});
if (gate(flags => flags.enableUnifiedSyncLane)) {
assertLog(['Count: 4']);
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
} else {
assertLog(['Count: 1']);
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
await waitForAll(['Count: 4']);
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
}
assertLog(['Count: 4']);
expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 4" />);
});
});

Expand Down Expand Up @@ -1613,11 +1606,7 @@ describe('ReactHooksWithNoopRenderer', () => {
// As a result we, somewhat surprisingly, commit them in the opposite order.
// This should be fine because any non-discrete set of work doesn't guarantee order
// and easily could've happened slightly later too.
if (gate(flags => flags.enableUnifiedSyncLane)) {
assertLog(['Will set count to 1', 'Count: 1']);
} else {
assertLog(['Will set count to 1', 'Count: 2', 'Count: 1']);
}
assertLog(['Will set count to 1', 'Count: 1']);

expect(ReactNoop).toMatchRenderedOutput(<span prop="Count: 1" />);
});
Expand Down
Loading

0 comments on commit c21bcd6

Please sign in to comment.