Skip to content

Commit 1ca80a7

Browse files
committed
Fixes in response to code review
1 parent 804df11 commit 1ca80a7

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

packages/react-reconciler/src/ReactDebugFiberPerf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ export function stopWorkLoopTimer(
387387
commitCountInCurrentWorkLoop = 0;
388388
let label = didCompleteRoot
389389
? '(React Tree Reconciliation: Completed Root)'
390-
: '(React Tree Reconciliation)';
390+
: '(React Tree Reconciliation: Yielded)';
391391
// Pause any measurements until the next loop.
392392
pauseTimers();
393393
endMark(label, '(React Tree Reconciliation)', warning);

packages/react-reconciler/src/ReactFiberScheduler.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -876,31 +876,41 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
876876
} while (true);
877877

878878
// We're done performing work. Time to clean up.
879-
const didCompleteRoot = nextUnitOfWork === null && isRootReadyForCommit;
880-
stopWorkLoopTimer(interruptedBy, didCompleteRoot);
881-
interruptedBy = null;
882-
isWorking = false;
879+
let didCompleteRoot = null;
883880

884881
// Yield back to main thread.
885882
if (didFatal) {
883+
stopWorkLoopTimer(interruptedBy, didCompleteRoot);
884+
interruptedBy = null;
885+
isWorking = false;
886886
// There was a fatal error.
887887
return null;
888888
} else if (nextUnitOfWork === null) {
889889
// We reached the root.
890890
if (isRootReadyForCommit) {
891+
didCompleteRoot = true;
892+
stopWorkLoopTimer(interruptedBy, didCompleteRoot);
893+
interruptedBy = null;
894+
isWorking = false;
891895
// The root successfully completed. It's ready for commit.
892896
root.pendingCommitExpirationTime = expirationTime;
893897
const finishedWork = root.current.alternate;
894898
return finishedWork;
895899
} else {
896900
// The root did not complete.
901+
stopWorkLoopTimer(interruptedBy, didCompleteRoot);
902+
interruptedBy = null;
903+
isWorking = false;
897904
invariant(
898905
false,
899906
'Expired work should have completed. This error is likely caused ' +
900907
'by a bug in React. Please file an issue.',
901908
);
902909
}
903910
} else {
911+
stopWorkLoopTimer(interruptedBy, didCompleteRoot);
912+
interruptedBy = null;
913+
isWorking = false;
904914
// There's more work to do, but we ran out of time. Yield back to
905915
// the renderer.
906916
return null;

0 commit comments

Comments
 (0)