Skip to content

Commit a9537b1

Browse files
committed
Unset flag on finish
1 parent 0e7bde4 commit a9537b1

11 files changed

+67
-53
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ import {
275275
pushRootMarkerInstance,
276276
TransitionTracingMarker,
277277
} from './ReactFiberTracingMarkerComponent.new';
278-
import { DefaultEventPriority } from './ReactEventPriorities';
278+
import {DefaultEventPriority} from './ReactEventPriorities';
279279

280280
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
281281

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ import {
275275
pushRootMarkerInstance,
276276
TransitionTracingMarker,
277277
} from './ReactFiberTracingMarkerComponent.old';
278-
import { DefaultEventPriority } from './ReactEventPriorities';
278+
import {DefaultEventPriority} from './ReactEventPriorities';
279279

280280
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
281281

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export const IdleLane: Lane = /* */ 0b0100000000000000000
8585
export const OffscreenLane: Lane = /* */ 0b1000000000000000000000000000000;
8686

8787
// Copied from ReactEventPriorities to avoid cyclic dependencies
88-
const DiscreteEventPriority = SyncLane;
8988
const DefaultEventPriority = SyncLane | (1 << 1);
9089

9190
// This function is used for the experimental timeline (react-devtools-timeline)
@@ -251,7 +250,8 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
251250
// Default priority updates should not interrupt transition updates. The
252251
// only difference between default updates and transition updates is that
253252
// default updates do not support refresh transitions.
254-
((!enableUnifiedSyncLane && nextLane === DefaultLane) &&
253+
(!enableUnifiedSyncLane &&
254+
nextLane === DefaultLane &&
255255
(wipLane & TransitionLanes) !== NoLanes)
256256
) {
257257
// Keep working on the existing in-progress tree. Do not interrupt.
@@ -608,7 +608,8 @@ export function markRootUpdated(
608608
updatePriority: EventPriority,
609609
) {
610610
root.pendingLanes |= updateLane;
611-
if ((root.pendingLanes & SyncLane) !== NoLane) {
611+
if ((updateLane & SyncLane) !== NoLane) {
612+
// Only set priority for the sync lane
612613
root.updatePriority = updatePriority;
613614
}
614615

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ export const IdleLane: Lane = /* */ 0b0100000000000000000
8585
export const OffscreenLane: Lane = /* */ 0b1000000000000000000000000000000;
8686

8787
// Copied from ReactEventPriorities to avoid cyclic dependencies
88-
const DiscreteEventPriority = SyncLane;
8988
const DefaultEventPriority = SyncLane | (1 << 1);
9089

9190
// This function is used for the experimental timeline (react-devtools-timeline)
@@ -251,7 +250,8 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes {
251250
// Default priority updates should not interrupt transition updates. The
252251
// only difference between default updates and transition updates is that
253252
// default updates do not support refresh transitions.
254-
((!enableUnifiedSyncLane && nextLane === DefaultLane) &&
253+
(!enableUnifiedSyncLane &&
254+
nextLane === DefaultLane &&
255255
(wipLane & TransitionLanes) !== NoLanes)
256256
) {
257257
// Keep working on the existing in-progress tree. Do not interrupt.
@@ -608,7 +608,8 @@ export function markRootUpdated(
608608
updatePriority: EventPriority,
609609
) {
610610
root.pendingLanes |= updateLane;
611-
if ((root.pendingLanes & SyncLane) !== NoLane) {
611+
if ((updateLane & SyncLane) !== NoLane) {
612+
// Only set priority for the sync lane
612613
root.updatePriority = updatePriority;
613614
}
614615

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import {
102102
} from './ReactFiberHotReloading.new';
103103
import ReactVersion from 'shared/ReactVersion';
104104
import {
105-
ContinuousEventPriority,
105+
DefaultEventPriority,
106106
DiscreteEventPriority,
107107
} from './ReactEventPriorities';
108108
export {registerMutableSourceForHydration} from './ReactMutableSource.new';
@@ -505,13 +505,7 @@ export function attemptContinuousHydration(fiber: Fiber): void {
505505
const root = enqueueConcurrentRenderForLane(fiber, lane);
506506
if (root !== null) {
507507
const eventTime = requestEventTime();
508-
scheduleUpdateOnFiber(
509-
root,
510-
fiber,
511-
lane,
512-
eventTime,
513-
ContinuousEventPriority,
514-
);
508+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, DefaultEventPriority);
515509
}
516510
markRetryLaneIfNotHydrated(fiber, lane);
517511
}

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ import {
102102
} from './ReactFiberHotReloading.old';
103103
import ReactVersion from 'shared/ReactVersion';
104104
import {
105-
ContinuousEventPriority,
105+
DefaultEventPriority,
106106
DiscreteEventPriority,
107107
} from './ReactEventPriorities';
108108
export {registerMutableSourceForHydration} from './ReactMutableSource.old';
@@ -505,13 +505,7 @@ export function attemptContinuousHydration(fiber: Fiber): void {
505505
const root = enqueueConcurrentRenderForLane(fiber, lane);
506506
if (root !== null) {
507507
const eventTime = requestEventTime();
508-
scheduleUpdateOnFiber(
509-
root,
510-
fiber,
511-
lane,
512-
eventTime,
513-
ContinuousEventPriority,
514-
);
508+
scheduleUpdateOnFiber(root, fiber, lane, eventTime, DefaultEventPriority);
515509
}
516510
markRetryLaneIfNotHydrated(fiber, lane);
517511
}

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ import {
2525
TotalLanes,
2626
createLaneMap,
2727
} from './ReactFiberLane.new';
28-
import {
29-
DiscreteEventPriority,
30-
NoEventPriority,
31-
DefaultEventPriority,
32-
} from './ReactEventPriorities.new';
28+
import {NoEventPriority} from './ReactEventPriorities.new';
3329
import {
3430
enableSuspenseCallback,
3531
enableCache,

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,7 @@ import {
2525
TotalLanes,
2626
createLaneMap,
2727
} from './ReactFiberLane.old';
28-
import {
29-
DiscreteEventPriority,
30-
NoEventPriority,
31-
DefaultEventPriority,
32-
} from './ReactEventPriorities.old';
28+
import {NoEventPriority} from './ReactEventPriorities.old';
3329
import {
3430
enableSuspenseCallback,
3531
enableCache,

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,11 @@ export function requestUpdateLane(fiber: Fiber): Lane {
633633
// This behavior is only a fallback. The flag only exists until we can roll
634634
// out the setState warning, since existing code might accidentally rely on
635635
// the current behavior.
636-
return pickArbitraryLane(workInProgressRootRenderLanes);
636+
const nextLane = pickArbitraryLane(workInProgressRootRenderLanes);
637+
if ((nextLane & SyncLane) === NoLane) {
638+
currentUpdatePriority = NoEventPriority;
639+
}
640+
return nextLane;
637641
}
638642

639643
const isTransition = requestCurrentTransition() !== NoTransition;
@@ -657,6 +661,10 @@ export function requestUpdateLane(fiber: Fiber): Lane {
657661
// All transitions within the same event are assigned the same lane.
658662
currentEventTransitionLane = claimNextTransitionLane();
659663
}
664+
if ((currentEventTransitionLane & SyncLane) === NoLane) {
665+
currentUpdatePriority = NoEventPriority;
666+
}
667+
660668
return currentEventTransitionLane;
661669
}
662670

@@ -665,8 +673,8 @@ export function requestUpdateLane(fiber: Fiber): Lane {
665673
//
666674
// TODO: Move this type conversion to the event priority module.
667675
const updatePriority = getCurrentUpdatePriority();
676+
currentUpdatePriority = updatePriority;
668677
if (updatePriority !== NoEventPriority) {
669-
currentUpdatePriority = updatePriority;
670678
if (updatePriority === DefaultEventPriority) {
671679
return enableUnifiedSyncLane ? SyncLane : DefaultLane;
672680
}
@@ -699,8 +707,10 @@ function requestRetryLane(fiber: Fiber) {
699707
// Special cases
700708
const mode = fiber.mode;
701709
if ((mode & ConcurrentMode) === NoMode) {
710+
currentUpdatePriority = DiscreteEventPriority;
702711
return (SyncLane: Lane);
703712
}
713+
currentUpdatePriority = DefaultEventPriority;
704714

705715
return claimNextRetryLane();
706716
}
@@ -845,7 +855,12 @@ export function scheduleInitialHydrationOnRoot(
845855
// match what was rendered on the server.
846856
const current = root.current;
847857
current.lanes = lane;
848-
markRootUpdated(root, lane, eventTime, root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority);
858+
markRootUpdated(
859+
root,
860+
lane,
861+
eventTime,
862+
root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority,
863+
);
849864
ensureRootIsScheduled(root, eventTime);
850865
}
851866

@@ -2701,8 +2716,7 @@ function commitRootImpl(
27012716
//// TODO: Need to clear the updatePriority inorder to remove the sync lane check
27022717
if (
27032718
(enableUnifiedSyncLane
2704-
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
2705-
prevRootUpdatePriority === DiscreteEventPriority
2719+
? prevRootUpdatePriority === DiscreteEventPriority
27062720
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
27072721
root.tag !== LegacyRoot
27082722
) {
@@ -2726,6 +2740,7 @@ function commitRootImpl(
27262740
}
27272741
} else {
27282742
nestedUpdateCount = 0;
2743+
root.updatePriority = NoEventPriority;
27292744
}
27302745

27312746
// If layout work was scheduled, flush it now.
@@ -3206,7 +3221,8 @@ function retryTimedOutBoundary(boundaryFiber: Fiber, retryLane: Lane) {
32063221
const eventTime = requestEventTime();
32073222
const root = enqueueConcurrentRenderForLane(boundaryFiber, retryLane);
32083223
if (root !== null) {
3209-
markRootUpdated(root, retryLane, eventTime, root.updatePriority);
3224+
// console.log(retryLane,root.updatePriority, currentUpdatePriority, new Error().stack);
3225+
markRootUpdated(root, retryLane, eventTime, currentUpdatePriority);
32103226
ensureRootIsScheduled(root, eventTime);
32113227
}
32123228
}

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,11 @@ export function requestUpdateLane(fiber: Fiber): Lane {
633633
// This behavior is only a fallback. The flag only exists until we can roll
634634
// out the setState warning, since existing code might accidentally rely on
635635
// the current behavior.
636-
return pickArbitraryLane(workInProgressRootRenderLanes);
636+
const nextLane = pickArbitraryLane(workInProgressRootRenderLanes);
637+
if ((nextLane & SyncLane) === NoLane) {
638+
currentUpdatePriority = NoEventPriority;
639+
}
640+
return nextLane;
637641
}
638642

639643
const isTransition = requestCurrentTransition() !== NoTransition;
@@ -657,6 +661,10 @@ export function requestUpdateLane(fiber: Fiber): Lane {
657661
// All transitions within the same event are assigned the same lane.
658662
currentEventTransitionLane = claimNextTransitionLane();
659663
}
664+
if ((currentEventTransitionLane & SyncLane) === NoLane) {
665+
currentUpdatePriority = NoEventPriority;
666+
}
667+
660668
return currentEventTransitionLane;
661669
}
662670

@@ -665,8 +673,8 @@ export function requestUpdateLane(fiber: Fiber): Lane {
665673
//
666674
// TODO: Move this type conversion to the event priority module.
667675
const updatePriority = getCurrentUpdatePriority();
676+
currentUpdatePriority = updatePriority;
668677
if (updatePriority !== NoEventPriority) {
669-
currentUpdatePriority = updatePriority;
670678
if (updatePriority === DefaultEventPriority) {
671679
return enableUnifiedSyncLane ? SyncLane : DefaultLane;
672680
}
@@ -699,8 +707,10 @@ function requestRetryLane(fiber: Fiber) {
699707
// Special cases
700708
const mode = fiber.mode;
701709
if ((mode & ConcurrentMode) === NoMode) {
710+
currentUpdatePriority = DiscreteEventPriority;
702711
return (SyncLane: Lane);
703712
}
713+
currentUpdatePriority = DefaultEventPriority;
704714

705715
return claimNextRetryLane();
706716
}
@@ -845,7 +855,12 @@ export function scheduleInitialHydrationOnRoot(
845855
// match what was rendered on the server.
846856
const current = root.current;
847857
current.lanes = lane;
848-
markRootUpdated(root, lane, eventTime, root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority);
858+
markRootUpdated(
859+
root,
860+
lane,
861+
eventTime,
862+
root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority,
863+
);
849864
ensureRootIsScheduled(root, eventTime);
850865
}
851866

@@ -2701,8 +2716,7 @@ function commitRootImpl(
27012716
//// TODO: Need to clear the updatePriority inorder to remove the sync lane check
27022717
if (
27032718
(enableUnifiedSyncLane
2704-
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
2705-
prevRootUpdatePriority === DiscreteEventPriority
2719+
? prevRootUpdatePriority === DiscreteEventPriority
27062720
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
27072721
root.tag !== LegacyRoot
27082722
) {
@@ -2726,6 +2740,7 @@ function commitRootImpl(
27262740
}
27272741
} else {
27282742
nestedUpdateCount = 0;
2743+
root.updatePriority = NoEventPriority;
27292744
}
27302745

27312746
// If layout work was scheduled, flush it now.
@@ -3206,7 +3221,8 @@ function retryTimedOutBoundary(boundaryFiber: Fiber, retryLane: Lane) {
32063221
const eventTime = requestEventTime();
32073222
const root = enqueueConcurrentRenderForLane(boundaryFiber, retryLane);
32083223
if (root !== null) {
3209-
markRootUpdated(root, retryLane, eventTime, root.updatePriority);
3224+
// console.log(retryLane,root.updatePriority, currentUpdatePriority, new Error().stack);
3225+
markRootUpdated(root, retryLane, eventTime, currentUpdatePriority);
32103226
ensureRootIsScheduled(root, eventTime);
32113227
}
32123228
}

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('DebugTracing', () => {
1818

1919
const SYNC_LANE_STRING = '0b0000000000000000000000000000001';
2020
const RETRY_LANE_STRING = '0b0000000010000000000000000000000';
21-
const SYNC_EVENT_PRIORITY = 1;
2221
const DEFAULT_EVENT_PRIORITY = 3;
2322

2423
global.IS_REACT_ACT_ENVIRONMENT = true;
@@ -133,9 +132,9 @@ describe('DebugTracing', () => {
133132
expect(Scheduler).toFlushUntilNextPaint([]);
134133

135134
expect(logs).toEqual([
136-
`group: ⚛️ render (${RETRY_LANE_STRING}) (${SYNC_EVENT_PRIORITY})`,
135+
`group: ⚛️ render (${RETRY_LANE_STRING}) (0)`,
137136
'log: <Example/>',
138-
`groupEnd: ⚛️ render (${RETRY_LANE_STRING}) (${SYNC_EVENT_PRIORITY})`,
137+
`groupEnd: ⚛️ render (${RETRY_LANE_STRING}) (0)`,
139138
]);
140139
});
141140

@@ -209,9 +208,9 @@ describe('DebugTracing', () => {
209208
`group: ⚛️ render (${SYNC_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
210209
'log: <Wrapper/>',
211210
`groupEnd: ⚛️ render (${SYNC_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
212-
`group: ⚛️ render (${RETRY_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
211+
`group: ⚛️ render (${RETRY_LANE_STRING}) (0)`,
213212
'log: <Example/>',
214-
`groupEnd: ⚛️ render (${RETRY_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
213+
`groupEnd: ⚛️ render (${RETRY_LANE_STRING}) (0)`,
215214
]);
216215
});
217216

@@ -322,9 +321,10 @@ describe('DebugTracing', () => {
322321
);
323322
});
324323
expect(logs).toEqual([
325-
`group: ⚛️ passive effects (${SYNC_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
324+
// TODO: why does this become 0?
325+
`group: ⚛️ passive effects (${SYNC_LANE_STRING}) (0)`,
326326
`log: ⚛️ Example updated state (${SYNC_LANE_STRING})`,
327-
`groupEnd: ⚛️ passive effects (${SYNC_LANE_STRING}) (${DEFAULT_EVENT_PRIORITY})`,
327+
`groupEnd: ⚛️ passive effects (${SYNC_LANE_STRING}) (0)`,
328328
]);
329329
});
330330

0 commit comments

Comments
 (0)