diff --git a/packages/react-reconciler/src/ReactFiberBeginWork.js b/packages/react-reconciler/src/ReactFiberBeginWork.js index 7b5b2f72b1e0c..043181597d7e7 100644 --- a/packages/react-reconciler/src/ReactFiberBeginWork.js +++ b/packages/react-reconciler/src/ReactFiberBeginWork.js @@ -142,7 +142,6 @@ import { OffscreenLane, DefaultHydrationLane, SomeRetryLane, - NoTimestamp, includesSomeLane, laneToLanes, removeLanes, @@ -2876,15 +2875,8 @@ function updateDehydratedSuspenseComponent( // is one of the very rare times where we mutate the current tree // during the render phase. suspenseState.retryLane = attemptHydrationAtLane; - // TODO: Ideally this would inherit the event time of the current render - const eventTime = NoTimestamp; enqueueConcurrentRenderForLane(current, attemptHydrationAtLane); - scheduleUpdateOnFiber( - root, - current, - attemptHydrationAtLane, - eventTime, - ); + scheduleUpdateOnFiber(root, current, attemptHydrationAtLane); // Throw a special object that signals to the work loop that it should // interrupt the current render. diff --git a/packages/react-reconciler/src/ReactFiberClassComponent.js b/packages/react-reconciler/src/ReactFiberClassComponent.js index 7aa3d934f3b12..b071808a9117d 100644 --- a/packages/react-reconciler/src/ReactFiberClassComponent.js +++ b/packages/react-reconciler/src/ReactFiberClassComponent.js @@ -64,11 +64,7 @@ import { emptyContextObject, } from './ReactFiberContext'; import {readContext, checkIfContextChanged} from './ReactFiberNewContext'; -import { - requestEventTime, - requestUpdateLane, - scheduleUpdateOnFiber, -} from './ReactFiberWorkLoop'; +import {requestUpdateLane, scheduleUpdateOnFiber} from './ReactFiberWorkLoop'; import {logForceUpdateScheduled, logStateUpdateScheduled} from './DebugTracing'; import { markForceUpdateScheduled, @@ -213,8 +209,7 @@ const classComponentUpdater = { const root = enqueueUpdate(fiber, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); entangleTransitions(root, fiber, lane); } @@ -248,8 +243,7 @@ const classComponentUpdater = { const root = enqueueUpdate(fiber, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); entangleTransitions(root, fiber, lane); } @@ -283,8 +277,7 @@ const classComponentUpdater = { const root = enqueueUpdate(fiber, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); entangleTransitions(root, fiber, lane); } diff --git a/packages/react-reconciler/src/ReactFiberCommitWork.js b/packages/react-reconciler/src/ReactFiberCommitWork.js index 9ea1d95796267..b540929ce0352 100644 --- a/packages/react-reconciler/src/ReactFiberCommitWork.js +++ b/packages/react-reconciler/src/ReactFiberCommitWork.js @@ -18,7 +18,7 @@ import type { } from './ReactFiberConfig'; import type {Fiber, FiberRoot} from './ReactInternalTypes'; import type {Lanes} from './ReactFiberLane'; -import {NoTimestamp, SyncLane} from './ReactFiberLane'; +import {SyncLane} from './ReactFiberLane'; import type {SuspenseState, RetryQueue} from './ReactFiberSuspenseComponent'; import type {UpdateQueue} from './ReactFiberClassUpdateQueue'; import type {FunctionComponentUpdateQueue} from './ReactFiberHooks'; @@ -2415,7 +2415,7 @@ export function detachOffscreenInstance(instance: OffscreenInstance): void { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { instance._pendingVisibility |= OffscreenDetached; - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } @@ -2435,7 +2435,7 @@ export function attachOffscreenInstance(instance: OffscreenInstance): void { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { instance._pendingVisibility &= ~OffscreenDetached; - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 369a662cb61b1..4be1994114a32 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -70,7 +70,6 @@ import { isTransitionLane, markRootEntangled, markRootMutableRead, - NoTimestamp, } from './ReactFiberLane'; import { ContinuousEventPriority, @@ -101,7 +100,6 @@ import { getWorkInProgressRootRenderLanes, scheduleUpdateOnFiber, requestUpdateLane, - requestEventTime, markSkippedUpdateLanes, isInvalidExecutionContextForEventFunction, } from './ReactFiberWorkLoop'; @@ -1837,7 +1835,7 @@ function checkIfSnapshotChanged(inst: StoreInstance): boolean { function forceStoreRerender(fiber: Fiber) { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } @@ -2558,8 +2556,7 @@ function refreshCache(fiber: Fiber, seedKey: ?() => T, seedValue: T): void { const refreshUpdate = createLegacyQueueUpdate(lane); const root = enqueueLegacyQueueUpdate(provider, refreshUpdate, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, provider, lane, eventTime); + scheduleUpdateOnFiber(root, provider, lane); entangleLegacyQueueTransitions(root, provider, lane); } @@ -2623,8 +2620,7 @@ function dispatchReducerAction( } else { const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); entangleTransitionUpdate(root, queue, lane); } } @@ -2706,8 +2702,7 @@ function dispatchSetState( const root = enqueueConcurrentHookUpdate(fiber, queue, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); entangleTransitionUpdate(root, queue, lane); } } diff --git a/packages/react-reconciler/src/ReactFiberHotReloading.js b/packages/react-reconciler/src/ReactFiberHotReloading.js index ffb3ae8a0ee1b..3bc3755bb957a 100644 --- a/packages/react-reconciler/src/ReactFiberHotReloading.js +++ b/packages/react-reconciler/src/ReactFiberHotReloading.js @@ -23,7 +23,7 @@ import { import {enqueueConcurrentRenderForLane} from './ReactFiberConcurrentUpdates'; import {updateContainer} from './ReactFiberReconciler'; import {emptyContextObject} from './ReactFiberContext'; -import {SyncLane, NoTimestamp} from './ReactFiberLane'; +import {SyncLane} from './ReactFiberLane'; import { ClassComponent, FunctionComponent, @@ -328,7 +328,7 @@ function scheduleFibersWithFamiliesRecursively( if (needsRemount || needsRender) { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } if (child !== null && !needsRemount) { diff --git a/packages/react-reconciler/src/ReactFiberLane.js b/packages/react-reconciler/src/ReactFiberLane.js index 45c8810c7f477..835bf01193423 100644 --- a/packages/react-reconciler/src/ReactFiberLane.js +++ b/packages/react-reconciler/src/ReactFiberLane.js @@ -319,25 +319,6 @@ export function getNextLanes(root: FiberRoot, wipLanes: Lanes): Lanes { return nextLanes; } -export function getMostRecentEventTime(root: FiberRoot, lanes: Lanes): number { - const eventTimes = root.eventTimes; - - let mostRecentEventTime = NoTimestamp; - while (lanes > 0) { - const index = pickArbitraryLaneIndex(lanes); - const lane = 1 << index; - - const eventTime = eventTimes[index]; - if (eventTime > mostRecentEventTime) { - mostRecentEventTime = eventTime; - } - - lanes &= ~lane; - } - - return mostRecentEventTime; -} - function computeExpirationTime(lane: Lane, currentTime: number) { switch (lane) { case SyncHydrationLane: @@ -599,11 +580,7 @@ export function createLaneMap(initial: T): LaneMap { return laneMap; } -export function markRootUpdated( - root: FiberRoot, - updateLane: Lane, - eventTime: number, -) { +export function markRootUpdated(root: FiberRoot, updateLane: Lane) { root.pendingLanes |= updateLane; // If there are any suspended transitions, it's possible this new update @@ -622,12 +599,6 @@ export function markRootUpdated( root.suspendedLanes = NoLanes; root.pingedLanes = NoLanes; } - - const eventTimes = root.eventTimes; - const index = laneToIndex(updateLane); - // We can always overwrite an existing timestamp because we prefer the most - // recent event, and we assume time is monotonically increasing. - eventTimes[index] = eventTime; } export function markRootSuspended(root: FiberRoot, suspendedLanes: Lanes) { @@ -672,7 +643,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) { root.errorRecoveryDisabledLanes &= remainingLanes; const entanglements = root.entanglements; - const eventTimes = root.eventTimes; const expirationTimes = root.expirationTimes; const hiddenUpdates = root.hiddenUpdates; @@ -683,7 +653,6 @@ export function markRootFinished(root: FiberRoot, remainingLanes: Lanes) { const lane = 1 << index; entanglements[index] = NoLanes; - eventTimes[index] = NoTimestamp; expirationTimes[index] = NoTimestamp; const hiddenUpdatesForLane = hiddenUpdates[index]; diff --git a/packages/react-reconciler/src/ReactFiberReconciler.js b/packages/react-reconciler/src/ReactFiberReconciler.js index 5ac1ecaa4ea74..72e020f945c64 100644 --- a/packages/react-reconciler/src/ReactFiberReconciler.js +++ b/packages/react-reconciler/src/ReactFiberReconciler.js @@ -56,7 +56,6 @@ import { onScheduleRoot, } from './ReactFiberDevToolsHook'; import { - requestEventTime, requestUpdateLane, scheduleUpdateOnFiber, scheduleInitialHydrationOnRoot, @@ -84,7 +83,6 @@ import {StrictLegacyMode} from './ReactTypeOfMode'; import { SyncLane, SelectiveHydrationLane, - NoTimestamp, getHighestPriorityPendingLanes, higherPriorityLane, } from './ReactFiberLane'; @@ -311,9 +309,8 @@ export function createHydrationContainer( const update = createUpdate(lane); update.callback = callback !== undefined && callback !== null ? callback : null; - const eventTime = requestEventTime(); enqueueUpdate(current, update, lane); - scheduleInitialHydrationOnRoot(root, lane, eventTime); + scheduleInitialHydrationOnRoot(root, lane); return root; } @@ -379,8 +376,7 @@ export function updateContainer( const root = enqueueUpdate(current, update, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, current, lane, eventTime); + scheduleUpdateOnFiber(root, current, lane); entangleTransitions(root, current, lane); } @@ -427,8 +423,7 @@ export function attemptSynchronousHydration(fiber: Fiber): void { flushSync(() => { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, SyncLane, eventTime); + scheduleUpdateOnFiber(root, fiber, SyncLane); } }); // If we're still blocked after this, we need to increase @@ -471,8 +466,7 @@ export function attemptContinuousHydration(fiber: Fiber): void { const lane = SelectiveHydrationLane; const root = enqueueConcurrentRenderForLane(fiber, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); } markRetryLaneIfNotHydrated(fiber, lane); } @@ -486,8 +480,7 @@ export function attemptHydrationAtCurrentPriority(fiber: Fiber): void { const lane = requestUpdateLane(fiber); const root = enqueueConcurrentRenderForLane(fiber, lane); if (root !== null) { - const eventTime = requestEventTime(); - scheduleUpdateOnFiber(root, fiber, lane, eventTime); + scheduleUpdateOnFiber(root, fiber, lane); } markRetryLaneIfNotHydrated(fiber, lane); } @@ -666,7 +659,7 @@ if (__DEV__) { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } }; @@ -690,7 +683,7 @@ if (__DEV__) { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } }; @@ -715,7 +708,7 @@ if (__DEV__) { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } } }; @@ -728,7 +721,7 @@ if (__DEV__) { } const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } }; overridePropsDeletePath = (fiber: Fiber, path: Array) => { @@ -738,7 +731,7 @@ if (__DEV__) { } const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } }; overridePropsRenamePath = ( @@ -752,14 +745,14 @@ if (__DEV__) { } const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } }; scheduleUpdate = (fiber: Fiber) => { const root = enqueueConcurrentRenderForLane(fiber, SyncLane); if (root !== null) { - scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp); + scheduleUpdateOnFiber(root, fiber, SyncLane); } }; diff --git a/packages/react-reconciler/src/ReactFiberRoot.js b/packages/react-reconciler/src/ReactFiberRoot.js index 35daaf7c10dc4..7fd4802d0cc79 100644 --- a/packages/react-reconciler/src/ReactFiberRoot.js +++ b/packages/react-reconciler/src/ReactFiberRoot.js @@ -66,7 +66,6 @@ function FiberRootNode( this.next = null; this.callbackNode = null; this.callbackPriority = NoLane; - this.eventTimes = createLaneMap(NoLanes); this.expirationTimes = createLaneMap(NoTimestamp); this.pendingLanes = NoLanes; diff --git a/packages/react-reconciler/src/ReactFiberWorkLoop.js b/packages/react-reconciler/src/ReactFiberWorkLoop.js index d75cc2c47ff15..6f00533d3004d 100644 --- a/packages/react-reconciler/src/ReactFiberWorkLoop.js +++ b/packages/react-reconciler/src/ReactFiberWorkLoop.js @@ -130,7 +130,6 @@ import { NoLanes, NoLane, SyncLane, - NoTimestamp, claimNextTransitionLane, claimNextRetryLane, includesSyncLane, @@ -584,10 +583,6 @@ const NESTED_PASSIVE_UPDATE_LIMIT = 50; let nestedPassiveUpdateCount: number = 0; let rootWithPassiveNestedUpdates: FiberRoot | null = null; -// If two updates are scheduled within the same event, we should treat their -// event times as simultaneous, even if the actual clock time has advanced -// between the first and second call. -let currentEventTime: number = NoTimestamp; let currentEventTransitionLane: Lanes = NoLanes; let isRunningInsertionEffect = false; @@ -604,21 +599,6 @@ export function isWorkLoopSuspendedOnData(): boolean { return workInProgressSuspendedReason === SuspendedOnData; } -export function requestEventTime(): number { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - // We're inside React, so it's fine to read the actual time. - return now(); - } - // We're not inside React, so we may be in the middle of a browser event. - if (currentEventTime !== NoTimestamp) { - // Use the same start time for all updates until we enter React again. - return currentEventTime; - } - // This is the first update since React yielded. Compute a new start time. - currentEventTime = now(); - return currentEventTime; -} - export function getCurrentTime(): number { return now(); } @@ -707,7 +687,6 @@ export function scheduleUpdateOnFiber( root: FiberRoot, fiber: Fiber, lane: Lane, - eventTime: number, ) { if (__DEV__) { if (isRunningInsertionEffect) { @@ -737,7 +716,7 @@ export function scheduleUpdateOnFiber( } // Mark that the root has a pending update. - markRootUpdated(root, lane, eventTime); + markRootUpdated(root, lane); if ( (executionContext & RenderContext) !== NoLanes && @@ -838,11 +817,7 @@ export function scheduleUpdateOnFiber( } } -export function scheduleInitialHydrationOnRoot( - root: FiberRoot, - lane: Lane, - eventTime: number, -) { +export function scheduleInitialHydrationOnRoot(root: FiberRoot, lane: Lane) { // This is a special fork of scheduleUpdateOnFiber that is only used to // schedule the initial hydration of a root that has just been created. Most // of the stuff in scheduleUpdateOnFiber can be skipped. @@ -854,7 +829,7 @@ export function scheduleInitialHydrationOnRoot( // match what was rendered on the server. const current = root.current; current.lanes = lane; - markRootUpdated(root, lane, eventTime); + markRootUpdated(root, lane); ensureRootIsScheduled(root); } @@ -874,9 +849,6 @@ export function performConcurrentWorkOnRoot( resetNestedUpdateFlag(); } - // Since we know we're in a React event, we can clear the current - // event time. The next update will compute a new event time. - currentEventTime = NoTimestamp; currentEventTransitionLane = NoLanes; if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { @@ -3313,9 +3285,8 @@ function captureCommitPhaseErrorOnRoot( const errorInfo = createCapturedValueAtFiber(error, sourceFiber); const update = createRootErrorUpdate(rootFiber, errorInfo, (SyncLane: Lane)); const root = enqueueUpdate(rootFiber, update, (SyncLane: Lane)); - const eventTime = requestEventTime(); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); + markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } } @@ -3356,9 +3327,8 @@ export function captureCommitPhaseError( (SyncLane: Lane), ); const root = enqueueUpdate(fiber, update, (SyncLane: Lane)); - const eventTime = requestEventTime(); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); + markRootUpdated(root, SyncLane); ensureRootIsScheduled(root); } return; @@ -3493,10 +3463,9 @@ function retryTimedOutBoundary(boundaryFiber: Fiber, retryLane: Lane) { retryLane = requestRetryLane(boundaryFiber); } // TODO: Special case idle priority? - const eventTime = requestEventTime(); const root = enqueueConcurrentRenderForLane(boundaryFiber, retryLane); if (root !== null) { - markRootUpdated(root, retryLane, eventTime); + markRootUpdated(root, retryLane); ensureRootIsScheduled(root); } } diff --git a/packages/react-reconciler/src/ReactInternalTypes.js b/packages/react-reconciler/src/ReactInternalTypes.js index c7264083172f0..281186c53de0d 100644 --- a/packages/react-reconciler/src/ReactInternalTypes.js +++ b/packages/react-reconciler/src/ReactInternalTypes.js @@ -248,7 +248,6 @@ type BaseFiberRootProperties = { // task that the root will work on. callbackNode: any, callbackPriority: Lane, - eventTimes: LaneMap, expirationTimes: LaneMap, hiddenUpdates: LaneMap | null>,