Skip to content

Commit

Permalink
Wrap stopBaseRenderTimerIfRunning in ProfileMode conditional also
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed May 15, 2018
1 parent 68ed0bd commit 25c1d6a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
18 changes: 12 additions & 6 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import {
} from './ReactChildFiber';
import {processUpdateQueue} from './ReactUpdateQueue';
import {NoWork, Never} from './ReactFiberExpirationTime';
import {AsyncMode, StrictMode} from './ReactTypeOfMode';
import {AsyncMode, ProfileMode, StrictMode} from './ReactTypeOfMode';
import MAX_SIGNED_31_BIT_INT from './maxSigned31BitInt';

const {getCurrentFiberStackAddendum} = ReactDebugCurrentFiber;
Expand Down Expand Up @@ -396,7 +396,9 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
nextChildren = null;

if (enableProfilerTimer) {
stopBaseRenderTimerIfRunning();
if (workInProgress.mode & ProfileMode) {
stopBaseRenderTimerIfRunning();
}
}
} else {
if (__DEV__) {
Expand Down Expand Up @@ -1153,8 +1155,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
cancelWorkTimer(workInProgress);

if (enableProfilerTimer) {
// Don't update "base" render times for bailouts.
stopBaseRenderTimerIfRunning();
if (workInProgress.mode & ProfileMode) {
// Don't update "base" render times for bailouts.
stopBaseRenderTimerIfRunning();
}
}

// TODO: We should ideally be able to bail out early if the children have no
Expand All @@ -1179,8 +1183,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
cancelWorkTimer(workInProgress);

if (enableProfilerTimer) {
// Don't update "base" render times for bailouts.
stopBaseRenderTimerIfRunning();
if (workInProgress.mode & ProfileMode) {
// Don't update "base" render times for bailouts.
stopBaseRenderTimerIfRunning();
}
}

// TODO: Handle HostComponent tags here as well and call pushHostContext()?
Expand Down
18 changes: 11 additions & 7 deletions packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,10 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
clearCaughtError();

if (enableProfilerTimer) {
// Stop "base" render timer again (after the re-thrown error).
stopBaseRenderTimerIfRunning();
if (failedUnitOfWork.mode & ProfileMode) {
// Stop "base" render timer again (after the re-thrown error).
stopBaseRenderTimerIfRunning();
}
}
} else {
// If the begin phase did not fail the second time, set this pointer
Expand Down Expand Up @@ -1064,18 +1066,20 @@ export default function<T, P, I, TI, HI, PI, C, CC, CX, PL>(
try {
workLoop(isAsync);
} catch (thrownValue) {
if (enableProfilerTimer) {
// Stop "base" render timer in the event of an error.
stopBaseRenderTimerIfRunning();
}

if (nextUnitOfWork === null) {
// This is a fatal error.
didFatal = true;
onUncaughtError(thrownValue);
break;
}

if (enableProfilerTimer) {
if (nextUnitOfWork.mode & ProfileMode) {
// Stop "base" render timer in the event of an error.
stopBaseRenderTimerIfRunning();
}
}

if (__DEV__) {
// Reset global debug state
// We assume this is defined in DEV
Expand Down

0 comments on commit 25c1d6a

Please sign in to comment.