@@ -148,6 +148,7 @@ import {
148148 getCurrentUpdateLanePriority ,
149149 markStarvedLanesAsExpired ,
150150 getLanesToRetrySynchronouslyOnError ,
151+ getMostRecentEventTime ,
151152 markRootUpdated ,
152153 markRootSuspended as markRootSuspended_dontCallThisOneDirectly ,
153154 markRootPinged ,
@@ -271,8 +272,6 @@ const subtreeRenderLanesCursor: StackCursor<Lanes> = createCursor(NoLanes);
271272let workInProgressRootExitStatus: RootExitStatus = RootIncomplete;
272273// A fatal error, if one is thrown
273274let workInProgressRootFatalError: mixed = null;
274- // Most recent event time among processed updates during this render.
275- let workInProgressRootLatestProcessedEventTime: number = NoTimestamp;
276275let workInProgressRootLatestSuspenseTimeout: number = NoTimestamp;
277276let workInProgressRootCanSuspendUsingConfig: null | SuspenseConfig = null;
278277// "Included" lanes refer to lanes that were worked on during this render. It's
@@ -915,20 +914,21 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
915914 break ;
916915 }
917916
917+ const mostRecentEventTime = getMostRecentEventTime ( root , lanes ) ;
918918 let msUntilTimeout ;
919919 if ( workInProgressRootLatestSuspenseTimeout !== NoTimestamp ) {
920920 // We have processed a suspense config whose expiration time we
921921 // can use as the timeout.
922922 msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now ( ) ;
923- } else if ( workInProgressRootLatestProcessedEventTime === NoTimestamp ) {
923+ } else if ( mostRecentEventTime === NoTimestamp ) {
924924 // This should never normally happen because only new updates
925925 // cause delayed states, so we should have processed something.
926926 // However, this could also happen in an offscreen tree.
927927 msUntilTimeout = 0 ;
928928 } else {
929929 // If we didn't process a suspense config, compute a JND based on
930930 // the amount of time elapsed since the most recent event time.
931- const eventTimeMs = workInProgressRootLatestProcessedEventTime ;
931+ const eventTimeMs = mostRecentEventTime ;
932932 const timeElapsedMs = now ( ) - eventTimeMs ;
933933 msUntilTimeout = jnd ( timeElapsedMs ) - timeElapsedMs ;
934934 }
@@ -951,18 +951,19 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
951951 }
952952 case RootCompleted : {
953953 // The work completed. Ready to commit.
954+ const mostRecentEventTime = getMostRecentEventTime ( root , lanes ) ;
954955 if (
955956 // do not delay if we're inside an act() scope
956957 ! shouldForceFlushFallbacksInDEV ( ) &&
957- workInProgressRootLatestProcessedEventTime !== NoTimestamp &&
958+ mostRecentEventTime !== NoTimestamp &&
958959 workInProgressRootCanSuspendUsingConfig !== null
959960 ) {
960961 // If we have exceeded the minimum loading delay, which probably
961962 // means we have shown a spinner already, we might have to suspend
962963 // a bit longer to ensure that the spinner is shown for
963964 // enough time.
964965 const msUntilTimeout = computeMsUntilSuspenseLoadingDelay (
965- workInProgressRootLatestProcessedEventTime ,
966+ mostRecentEventTime ,
966967 workInProgressRootCanSuspendUsingConfig ,
967968 ) ;
968969 if ( msUntilTimeout > 10 ) {
@@ -1300,7 +1301,6 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes) {
13001301 workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes ;
13011302 workInProgressRootExitStatus = RootIncomplete ;
13021303 workInProgressRootFatalError = null ;
1303- workInProgressRootLatestProcessedEventTime = NoTimestamp ;
13041304 workInProgressRootLatestSuspenseTimeout = NoTimestamp ;
13051305 workInProgressRootCanSuspendUsingConfig = null ;
13061306 workInProgressRootSkippedLanes = NoLanes ;
@@ -1418,11 +1418,6 @@ export function markRenderEventTimeAndConfig(
14181418 eventTime : number ,
14191419 suspenseConfig : null | SuspenseConfig ,
14201420) : void {
1421- // Track the most recent event time of all updates processed in this batch.
1422- if ( workInProgressRootLatestProcessedEventTime < eventTime ) {
1423- workInProgressRootLatestProcessedEventTime = eventTime ;
1424- }
1425-
14261421 // Track the largest/latest timeout deadline in this batch.
14271422 // TODO: If there are two transitions in the same batch, shouldn't we
14281423 // choose the smaller one? Maybe this is because when an intermediate
0 commit comments