From 0e7bde42901bed54ef87ab1f384ad0405950cbfa Mon Sep 17 00:00:00 2001 From: Tianyu Yao Date: Thu, 3 Nov 2022 22:22:41 -0700 Subject: [PATCH] set flag more correctly --- .../react-reconciler/src/ReactFiberBeginWork.new.js | 4 ++-- .../react-reconciler/src/ReactFiberBeginWork.old.js | 4 ++-- packages/react-reconciler/src/ReactFiberLane.new.js | 10 ++-------- packages/react-reconciler/src/ReactFiberLane.old.js | 10 ++-------- packages/react-reconciler/src/ReactFiberRoot.new.js | 3 +-- packages/react-reconciler/src/ReactFiberRoot.old.js | 3 +-- .../react-reconciler/src/ReactFiberWorkLoop.new.js | 8 ++++---- .../react-reconciler/src/ReactFiberWorkLoop.old.js | 8 ++++---- 8 files changed, 18 insertions(+), 32 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.new.js b/packages/react-reconciler/src/ReactFiberBeginWork.new.js index 92b90ede2d..932c7dccd0 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.new.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.new.js @@ -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 diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.old.js b/packages/react-reconciler/src/ReactFiberBeginWork.old.js index 2b3aad9985..ee1bb1343b 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.old.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.old.js @@ -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 diff --git a/packages/react-reconciler/src/ReactFiberLane.new.js b/packages/react-reconciler/src/ReactFiberLane.new.js index e9acd51b28..bb75dc9dc8 100644 --- a/packages/react-reconciler/src/ReactFiberLane.new.js +++ b/packages/react-reconciler/src/ReactFiberLane.new.js @@ -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; diff --git a/packages/react-reconciler/src/ReactFiberLane.old.js b/packages/react-reconciler/src/ReactFiberLane.old.js index 5e0fc5db3d..4bc9d77b92 100644 --- a/packages/react-reconciler/src/ReactFiberLane.old.js +++ b/packages/react-reconciler/src/ReactFiberLane.old.js @@ -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; diff --git a/packages/react-reconciler/src/ReactFiberRoot.new.js b/packages/react-reconciler/src/ReactFiberRoot.new.js index 864b7088c6..111367056c 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.new.js +++ b/packages/react-reconciler/src/ReactFiberRoot.new.js @@ -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); diff --git a/packages/react-reconciler/src/ReactFiberRoot.old.js b/packages/react-reconciler/src/ReactFiberRoot.old.js index 465eea3aea..ef9fac59ae 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.old.js +++ b/packages/react-reconciler/src/ReactFiberRoot.old.js @@ -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); diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js index 8725682268..1f5bea2525 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.new.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.new.js @@ -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 ) { diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js index 7a5e7b9313..5211384784 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.old.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.old.js @@ -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 ) {