@samitouri / QOS-React-2 / commits / f342a2399f

SuspenseList: Reschedule at same priority (#18738)

SuspenseList progressively renders items even if the list is CPU bound, i.e. it isn't waiting for missing data. It does this by showing a fallback for the remaining items, committing the items in that have already finished, then starting a new render to continue working on the rest. When it schedules that subsequent render, it uses a slightly lower priority than the current render: `renderExpirationTime - 1`. This commit changes it to reschedule at `renderExpirationTime` instead. I don't know what the original motivation was for bumping the expiration time slightly lower. The comment says that the priorities of the two renders are the same (which makes sense to me) so I imagine it was motivated by some implementation detail. I don't think it's necessary anymore, though perhaps it was when it was originally written. If it is still necessary, we should write a test case that illustrates why.

Andrew Clark committed Apr 25, 2020 at 20:27 UTC f342a2399fe121d84cf488adc8f22805b2278370
1 file changed +3 -9
packages/react-reconciler/src/ReactFiberCompleteWork.new.js
+3 -9
@@ -127,11 +127,7 @@ import {
127 renderHasNotSuspendedYet,
128 } from './ReactFiberWorkLoop.new';
129 import {createFundamentalStateInstance} from './ReactFiberFundamental.new';
130 -import {
131 - Never,
132 - isSameOrHigherPriority,
133 - bumpPriorityLower,
134 -} from './ReactFiberExpirationTime.new';
130 +import {Never, isSameOrHigherPriority} from './ReactFiberExpirationTime.new';
131 import {resetChildFibers} from './ReactChildFiber.new';
132 import {updateDeprecatedEventListeners} from './ReactFiberDeprecatedEvents.new';
133 import {createScopeMethods} from './ReactFiberScope.new';
@@ -1118,11 +1114,9 @@ function completeWork(
1114 // them, then they really have the same priority as this render.
1115 // So we'll pick it back up the very next render pass once we've had
1116 // an opportunity to yield for paint.
1121 -
1122 - const nextPriority = bumpPriorityLower(renderExpirationTime);
1123 - workInProgress.expirationTime_opaque = workInProgress.childExpirationTime_opaque = nextPriority;
1117 + workInProgress.expirationTime_opaque = renderExpirationTime;
1118 if (enableSchedulerTracing) {
1125 - markSpawnedWork(nextPriority);
1119 + markSpawnedWork(renderExpirationTime);
1120 }
1121 }
1122 }