set flag more correctly

This commit is contained in:
Tianyu Yao
2022-11-03 22:22:41 -07:00
parent 38802826ec
commit 0e7bde4290
8 changed files with 18 additions and 32 deletions
@@ -275,7 +275,7 @@ import {
pushRootMarkerInstance,
TransitionTracingMarker,
} from './ReactFiberTracingMarkerComponent.new';
import {NoEventPriority} from './ReactEventPriorities.new';
import { DefaultEventPriority } from './ReactEventPriorities';
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -2822,7 +2822,7 @@ function updateDehydratedSuspenseComponent(
current,
attemptHydrationAtLane,
eventTime,
NoEventPriority,
DefaultEventPriority,
);
} else {
// We have already tried to ping at a higher priority than we're rendering with
@@ -275,7 +275,7 @@ import {
pushRootMarkerInstance,
TransitionTracingMarker,
} from './ReactFiberTracingMarkerComponent.old';
import {NoEventPriority} from './ReactEventPriorities.old';
import { DefaultEventPriority } from './ReactEventPriorities';
const ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
@@ -2822,7 +2822,7 @@ function updateDehydratedSuspenseComponent(
current,
attemptHydrationAtLane,
eventTime,
NoEventPriority,
DefaultEventPriority,
);
} else {
// We have already tried to ping at a higher priority than we're rendering with
@@ -11,7 +11,6 @@ import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Transition} from './ReactFiberTracingMarkerComponent.new';
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates.new';
import type {EventPriority} from './ReactEventPriorities.new';
import {LegacyRoot} from './ReactRootTags';
// TODO: Ideally these types would be opaque but that doesn't work well with
// our reconciler fork infra, since these leak into non-reconciler packages.
@@ -640,9 +639,6 @@ export function markRootUpdated(
export function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) {
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
if ((root.suspendedLanes & SyncLane) !== NoLane) {
root.updatePriority = DefaultEventPriority;
}
// The suspended lanes are no longer CPU-bound. Clear their expiration times.
const expirationTimes = root.expirationTimes;
let lanes = suspendedLanes;
@@ -672,10 +668,8 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
const noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
root.pendingLanes = remainingLanes;
if ((root.pendingLanes & SyncLane) !== NoLane) {
root.updatePriority =
root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority;
}
// TODO: clearing the priority causes priority to be missing in retryTimedOutBoundary
// Let's try everything again
root.suspendedLanes = NoLanes;
@@ -11,7 +11,6 @@ import type {Fiber, FiberRoot} from './ReactInternalTypes';
import type {Transition} from './ReactFiberTracingMarkerComponent.old';
import type {ConcurrentUpdate} from './ReactFiberConcurrentUpdates.old';
import type {EventPriority} from './ReactEventPriorities.old';
import {LegacyRoot} from './ReactRootTags';
// TODO: Ideally these types would be opaque but that doesn't work well with
// our reconciler fork infra, since these leak into non-reconciler packages.
@@ -640,9 +639,6 @@ export function markRootUpdated(
export function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) {
root.suspendedLanes |= suspendedLanes;
root.pingedLanes &= ~suspendedLanes;
if ((root.suspendedLanes & SyncLane) !== NoLane) {
root.updatePriority = DefaultEventPriority;
}
// The suspended lanes are no longer CPU-bound. Clear their expiration times.
const expirationTimes = root.expirationTimes;
let lanes = suspendedLanes;
@@ -672,10 +668,8 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) {
const noLongerPendingLanes = root.pendingLanes & ~remainingLanes;
root.pendingLanes = remainingLanes;
if ((root.pendingLanes & SyncLane) !== NoLane) {
root.updatePriority =
root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority;
}
// TODO: clearing the priority causes priority to be missing in retryTimedOutBoundary
// Let's try everything again
root.suspendedLanes = NoLanes;
@@ -66,8 +66,7 @@ function FiberRootNode(
this.pendingContext = null;
this.callbackNode = null;
this.callbackPriority = NoEventPriority;
this.updatePriority =
tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority;
this.updatePriority = NoEventPriority;
this.eventTimes = createLaneMap(NoLanes);
this.expirationTimes = createLaneMap(NoTimestamp);
@@ -66,8 +66,7 @@ function FiberRootNode(
this.pendingContext = null;
this.callbackNode = null;
this.callbackPriority = NoEventPriority;
this.updatePriority =
tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority;
this.updatePriority = NoEventPriority;
this.eventTimes = createLaneMap(NoLanes);
this.expirationTimes = createLaneMap(NoTimestamp);
@@ -845,7 +845,7 @@ export function scheduleInitialHydrationOnRoot(
// match what was rendered on the server.
const current = root.current;
current.lanes = lane;
markRootUpdated(root, lane, eventTime, root.updatePriority);
markRootUpdated(root, lane, eventTime, root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority);
ensureRootIsScheduled(root, eventTime);
}
@@ -2497,7 +2497,7 @@ function commitRootImpl(
}
}
const rootUpdatePriorityBeforeLayoutEffect = root.updatePriority;
const prevRootUpdatePriority = root.updatePriority;
// Check if there are any effects in the whole tree.
// TODO: This is left over from the effect list implementation, where we had
// to check for the existence of `firstEffect` to satisfy Flow. I think the
@@ -2698,11 +2698,11 @@ function commitRootImpl(
// TODO: We can optimize this by not scheduling the callback earlier. Since we
// currently schedule the callback in multiple places, will wait until those
// are consolidated.
//// TODO: Should we flushPassiveEffects When `pendingPassiveEffectsLanes` is a retry lane?
//// TODO: Need to clear the updatePriority inorder to remove the sync lane check
if (
(enableUnifiedSyncLane
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
rootUpdatePriorityBeforeLayoutEffect === DiscreteEventPriority
prevRootUpdatePriority === DiscreteEventPriority
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
root.tag !== LegacyRoot
) {
@@ -845,7 +845,7 @@ export function scheduleInitialHydrationOnRoot(
// match what was rendered on the server.
const current = root.current;
current.lanes = lane;
markRootUpdated(root, lane, eventTime, root.updatePriority);
markRootUpdated(root, lane, eventTime, root.tag === LegacyRoot ? DiscreteEventPriority : DefaultEventPriority);
ensureRootIsScheduled(root, eventTime);
}
@@ -2497,7 +2497,7 @@ function commitRootImpl(
}
}
const rootUpdatePriorityBeforeLayoutEffect = root.updatePriority;
const prevRootUpdatePriority = root.updatePriority;
// Check if there are any effects in the whole tree.
// TODO: This is left over from the effect list implementation, where we had
// to check for the existence of `firstEffect` to satisfy Flow. I think the
@@ -2698,11 +2698,11 @@ function commitRootImpl(
// TODO: We can optimize this by not scheduling the callback earlier. Since we
// currently schedule the callback in multiple places, will wait until those
// are consolidated.
//// TODO: Should we flushPassiveEffects When `pendingPassiveEffectsLanes` is a retry lane?
//// TODO: Need to clear the updatePriority inorder to remove the sync lane check
if (
(enableUnifiedSyncLane
? includesSomeLane(pendingPassiveEffectsLanes, SyncLane) &&
rootUpdatePriorityBeforeLayoutEffect === DiscreteEventPriority
prevRootUpdatePriority === DiscreteEventPriority
: includesSomeLane(pendingPassiveEffectsLanes, SyncLane)) &&
root.tag !== LegacyRoot
) {