@@ -171,6 +171,7 @@ import {
171171 getCurrentUpdateLanePriority ,
172172 markStarvedLanesAsExpired ,
173173 getLanesToRetrySynchronouslyOnError ,
174+ getMostRecentEventTime ,
174175 markRootUpdated ,
175176 markRootSuspended as markRootSuspended_dontCallThisOneDirectly ,
176177 markRootPinged ,
@@ -294,8 +295,6 @@ const subtreeRenderLanesCursor: StackCursor<Lanes> = createCursor(NoLanes);
294295let workInProgressRootExitStatus: RootExitStatus = RootIncomplete;
295296// A fatal error, if one is thrown
296297let workInProgressRootFatalError: mixed = null;
297- // Most recent event time among processed updates during this render.
298- let workInProgressRootLatestProcessedEventTime: number = NoTimestamp;
299298let workInProgressRootLatestSuspenseTimeout: number = NoTimestamp;
300299let workInProgressRootCanSuspendUsingConfig: null | SuspenseConfig = null;
301300// "Included" lanes refer to lanes that were worked on during this render. It's
@@ -938,20 +937,21 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
938937 break ;
939938 }
940939
940+ const mostRecentEventTime = getMostRecentEventTime ( root , lanes ) ;
941941 let msUntilTimeout ;
942942 if ( workInProgressRootLatestSuspenseTimeout !== NoTimestamp ) {
943943 // We have processed a suspense config whose expiration time we
944944 // can use as the timeout.
945945 msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now ( ) ;
946- } else if ( workInProgressRootLatestProcessedEventTime === NoTimestamp ) {
946+ } else if ( mostRecentEventTime === NoTimestamp ) {
947947 // This should never normally happen because only new updates
948948 // cause delayed states, so we should have processed something.
949949 // However, this could also happen in an offscreen tree.
950950 msUntilTimeout = 0 ;
951951 } else {
952952 // If we didn't process a suspense config, compute a JND based on
953953 // the amount of time elapsed since the most recent event time.
954- const eventTimeMs = workInProgressRootLatestProcessedEventTime ;
954+ const eventTimeMs = mostRecentEventTime ;
955955 const timeElapsedMs = now ( ) - eventTimeMs ;
956956 msUntilTimeout = jnd ( timeElapsedMs ) - timeElapsedMs ;
957957 }
@@ -974,18 +974,19 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) {
974974 }
975975 case RootCompleted : {
976976 // The work completed. Ready to commit.
977+ const mostRecentEventTime = getMostRecentEventTime ( root , lanes ) ;
977978 if (
978979 // do not delay if we're inside an act() scope
979980 ! shouldForceFlushFallbacksInDEV ( ) &&
980- workInProgressRootLatestProcessedEventTime !== NoTimestamp &&
981+ mostRecentEventTime !== NoTimestamp &&
981982 workInProgressRootCanSuspendUsingConfig !== null
982983 ) {
983984 // If we have exceeded the minimum loading delay, which probably
984985 // means we have shown a spinner already, we might have to suspend
985986 // a bit longer to ensure that the spinner is shown for
986987 // enough time.
987988 const msUntilTimeout = computeMsUntilSuspenseLoadingDelay (
988- workInProgressRootLatestProcessedEventTime ,
989+ mostRecentEventTime ,
989990 workInProgressRootCanSuspendUsingConfig ,
990991 ) ;
991992 if ( msUntilTimeout > 10 ) {
@@ -1323,7 +1324,6 @@ function prepareFreshStack(root: FiberRoot, lanes: Lanes) {
13231324 workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes ;
13241325 workInProgressRootExitStatus = RootIncomplete ;
13251326 workInProgressRootFatalError = null ;
1326- workInProgressRootLatestProcessedEventTime = NoTimestamp ;
13271327 workInProgressRootLatestSuspenseTimeout = NoTimestamp ;
13281328 workInProgressRootCanSuspendUsingConfig = null ;
13291329 workInProgressRootSkippedLanes = NoLanes ;
@@ -1441,11 +1441,6 @@ export function markRenderEventTimeAndConfig(
14411441 eventTime : number ,
14421442 suspenseConfig : null | SuspenseConfig ,
14431443) : void {
1444- // Track the most recent event time of all updates processed in this batch.
1445- if ( workInProgressRootLatestProcessedEventTime < eventTime ) {
1446- workInProgressRootLatestProcessedEventTime = eventTime ;
1447- }
1448-
14491444 // Track the largest/latest timeout deadline in this batch.
14501445 // TODO: If there are two transitions in the same batch, shouldn't we
14511446 // choose the smaller one? Maybe this is because when an intermediate
0 commit comments