Skip to content

Commit 1fd3906

Browse files
authored
Remove "Waiting for async callback" User Timing measurement (#16379)
* Remove "Waiting for async callback" User Timing measurement * Fix User Timing in PROD mode
1 parent 89bbffe commit 1fd3906

File tree

4 files changed

+44
-117
lines changed

4 files changed

+44
-117
lines changed

packages/react-reconciler/src/ReactFiber.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import warningWithoutStack from 'shared/warningWithoutStack';
3131
import {
3232
enableProfilerTimer,
3333
enableFundamentalAPI,
34+
enableUserTimingAPI,
3435
} from 'shared/ReactFeatureFlags';
3536
import {NoEffect, Placement} from 'shared/ReactSideEffectTags';
3637
import {ConcurrentRoot, BatchedRoot} from 'shared/ReactRootTags';
@@ -245,11 +246,7 @@ export type Fiber = {|
245246
_debugHookTypes?: Array<HookType> | null,
246247
|};
247248

248-
let debugCounter;
249-
250-
if (__DEV__) {
251-
debugCounter = 1;
252-
}
249+
let debugCounter = 1;
253250

254251
function FiberNode(
255252
tag: WorkTag,
@@ -319,11 +316,16 @@ function FiberNode(
319316
this.treeBaseDuration = 0;
320317
}
321318

322-
if (__DEV__) {
319+
// This is normally DEV-only except www when it adds listeners.
320+
// TODO: remove the User Timing integration in favor of Root Events.
321+
if (enableUserTimingAPI) {
323322
this._debugID = debugCounter++;
323+
this._debugIsCurrentlyTiming = false;
324+
}
325+
326+
if (__DEV__) {
324327
this._debugSource = null;
325328
this._debugOwner = null;
326-
this._debugIsCurrentlyTiming = false;
327329
this._debugNeedsRemount = false;
328330
this._debugHookTypes = null;
329331
if (!hasBadMapPolyfill && typeof Object.preventExtensions === 'function') {

packages/react-reconciler/src/ReactFiberWorkLoop.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ import {
152152
import {
153153
recordEffect,
154154
recordScheduleUpdate,
155-
startRequestCallbackTimer,
156-
stopRequestCallbackTimer,
157155
startWorkTimer,
158156
stopWorkTimer,
159157
stopFailedWorkTimer,
@@ -546,16 +544,6 @@ function scheduleCallbackForRoot(
546544
),
547545
options,
548546
);
549-
if (
550-
enableUserTimingAPI &&
551-
expirationTime !== Sync &&
552-
(executionContext & (RenderContext | CommitContext)) === NoContext
553-
) {
554-
// Scheduled an async callback, and we're not already working. Add an
555-
// entry to the flamegraph that shows we're waiting for a callback
556-
// to fire.
557-
startRequestCallbackTimer();
558-
}
559547
}
560548
}
561549

@@ -816,11 +804,6 @@ function renderRoot(
816804
'Should not already be working.',
817805
);
818806

819-
if (enableUserTimingAPI && expirationTime !== Sync) {
820-
const didExpire = isSync;
821-
stopRequestCallbackTimer(didExpire);
822-
}
823-
824807
if (root.firstPendingTime < expirationTime) {
825808
// If there's no work left at this expiration time, exit immediately. This
826809
// happens when multiple callbacks are scheduled for a single root, but an
@@ -964,9 +947,6 @@ function renderRoot(
964947
if (workInProgress !== null) {
965948
// There's still work left over. Return a continuation.
966949
stopInterruptedWorkLoopTimer();
967-
if (expirationTime !== Sync) {
968-
startRequestCallbackTimer();
969-
}
970950
return renderRoot.bind(null, root, expirationTime);
971951
}
972952
}

packages/react-reconciler/src/__tests__/ReactIncrementalPerf-test.internal.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ describe('ReactDebugFiberPerf', () => {
8989
// We don't use the overload with three arguments.
9090
measure(label, markName) {
9191
if (markName !== activeMeasure.markName) {
92+
// Fail the test.
93+
console.error(
94+
'Unexpected measure() call: "%s". Active mark is "%s".',
95+
markName,
96+
activeMeasure.markName,
97+
);
98+
// This exception will be caught and ignored
99+
// because in the real implementation, we don't want
100+
// to spam the console due to a React bug.
92101
throw new Error('Unexpected measure() call.');
93102
}
94103
// Step one level up

0 commit comments

Comments
 (0)