Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions packages/react-client/src/ReactFlightPerformanceTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export function logComponentRender(
const entryName =
isPrimaryEnv || env === undefined ? name : name + ' [' + env + ']';
const debugTask = componentInfo.debugTask;
const measureName = '\u200b' + entryName;
if (__DEV__ && debugTask) {
const properties: Array<[string, string]> = [];
if (componentInfo.key != null) {
Expand All @@ -110,9 +111,10 @@ export function logComponentRender(
if (componentInfo.props != null) {
addObjectToProperties(componentInfo.props, properties, 0, '');
}

debugTask.run(
// $FlowFixMe[method-unbinding]
performance.measure.bind(performance, '\u200b' + entryName, {
performance.measure.bind(performance, measureName, {
start: startTime < 0 ? 0 : startTime,
end: childrenEndTime,
detail: {
Expand All @@ -125,9 +127,10 @@ export function logComponentRender(
},
}),
);
performance.clearMeasures(measureName);
} else {
console.timeStamp(
'\u200b' + entryName,
measureName,
startTime < 0 ? 0 : startTime,
childrenEndTime,
trackNames[trackIdx],
Expand All @@ -152,6 +155,7 @@ export function logComponentAborted(
const isPrimaryEnv = env === rootEnv;
const entryName =
isPrimaryEnv || env === undefined ? name : name + ' [' + env + ']';
const measureName = '\u200b' + entryName;
if (__DEV__) {
const properties: Array<[string, string]> = [
[
Expand All @@ -165,7 +169,8 @@ export function logComponentAborted(
if (componentInfo.props != null) {
addObjectToProperties(componentInfo.props, properties, 0, '');
}
performance.measure('\u200b' + entryName, {

performance.measure(measureName, {
start: startTime < 0 ? 0 : startTime,
end: childrenEndTime,
detail: {
Expand All @@ -178,9 +183,10 @@ export function logComponentAborted(
},
},
});
performance.clearMeasures(measureName);
} else {
console.timeStamp(
entryName,
measureName,
startTime < 0 ? 0 : startTime,
childrenEndTime,
trackNames[trackIdx],
Expand All @@ -206,6 +212,7 @@ export function logComponentErrored(
const isPrimaryEnv = env === rootEnv;
const entryName =
isPrimaryEnv || env === undefined ? name : name + ' [' + env + ']';
const measureName = '\u200b' + entryName;
if (__DEV__) {
const message =
typeof error === 'object' &&
Expand All @@ -222,7 +229,8 @@ export function logComponentErrored(
if (componentInfo.props != null) {
addObjectToProperties(componentInfo.props, properties, 0, '');
}
performance.measure('\u200b' + entryName, {

performance.measure(measureName, {
start: startTime < 0 ? 0 : startTime,
end: childrenEndTime,
detail: {
Expand All @@ -235,9 +243,10 @@ export function logComponentErrored(
},
},
});
performance.clearMeasures(measureName);
} else {
console.timeStamp(
entryName,
measureName,
startTime < 0 ? 0 : startTime,
childrenEndTime,
trackNames[trackIdx],
Expand Down Expand Up @@ -397,6 +406,7 @@ export function logComponentAwaitAborted(
},
}),
);
performance.clearMeasures(entryName);
} else {
console.timeStamp(
entryName,
Expand Down Expand Up @@ -453,6 +463,7 @@ export function logComponentAwaitErrored(
},
}),
);
performance.clearMeasures(entryName);
} else {
console.timeStamp(
entryName,
Expand Down Expand Up @@ -514,6 +525,7 @@ export function logComponentAwait(
},
}),
);
performance.clearMeasures(entryName);
} else {
console.timeStamp(
entryName,
Expand All @@ -538,6 +550,7 @@ export function logIOInfoErrored(
const description = getIODescription(error);
const entryName = getIOShortName(ioInfo, description, ioInfo.env, rootEnv);
const debugTask = ioInfo.debugTask;
const measureName = '\u200b' + entryName;
if (__DEV__ && debugTask) {
const message =
typeof error === 'object' &&
Expand All @@ -550,9 +563,10 @@ export function logIOInfoErrored(
const properties = [['rejected with', message]];
const tooltipText =
getIOLongName(ioInfo, description, ioInfo.env, rootEnv) + ' Rejected';

debugTask.run(
// $FlowFixMe[method-unbinding]
performance.measure.bind(performance, '\u200b' + entryName, {
performance.measure.bind(performance, measureName, {
start: startTime < 0 ? 0 : startTime,
end: endTime,
detail: {
Expand All @@ -565,9 +579,10 @@ export function logIOInfoErrored(
},
}),
);
performance.clearMeasures(measureName);
} else {
console.timeStamp(
entryName,
measureName,
startTime < 0 ? 0 : startTime,
endTime,
IO_TRACK,
Expand All @@ -590,6 +605,7 @@ export function logIOInfo(
const entryName = getIOShortName(ioInfo, description, ioInfo.env, rootEnv);
const color = getIOColor(entryName);
const debugTask = ioInfo.debugTask;
const measureName = '\u200b' + entryName;
if (__DEV__ && debugTask) {
const properties: Array<[string, string]> = [];
if (typeof value === 'object' && value !== null) {
Expand All @@ -605,7 +621,7 @@ export function logIOInfo(
);
debugTask.run(
// $FlowFixMe[method-unbinding]
performance.measure.bind(performance, '\u200b' + entryName, {
performance.measure.bind(performance, measureName, {
start: startTime < 0 ? 0 : startTime,
end: endTime,
detail: {
Expand All @@ -618,9 +634,10 @@ export function logIOInfo(
},
}),
);
performance.clearMeasures(measureName);
} else {
console.timeStamp(
entryName,
measureName,
startTime < 0 ? 0 : startTime,
endTime,
IO_TRACK,
Expand Down
13 changes: 13 additions & 0 deletions packages/react-devtools-shared/src/devtools/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import type {
ComponentFilter,
ElementType,
SuspenseNode,
Rect,
} from 'react-devtools-shared/src/frontend/types';
import type {
FrontendBridge,
Expand Down Expand Up @@ -99,6 +100,10 @@ export type Capabilities = {
supportsAdvancedProfiling: AdvancedProfiling,
};

function isNonZeroRect(rect: Rect) {
return rect.width > 0 || rect.height > 0 || rect.x > 0 || rect.y > 0;
}

/**
* The store is the single source of truth for updates from the backend.
* ContextProviders can subscribe to the Store for specific things they want to provide.
Expand Down Expand Up @@ -918,7 +923,15 @@ export default class Store extends EventEmitter<{
if (current === undefined) {
continue;
}
// Ignore any suspense boundaries that has no visual representation as this is not
// part of the visible loading sequence.
// TODO: Consider making visible meta data and other side-effects get virtual rects.
const hasRects =
current.rects !== null &&
current.rects.length > 0 &&
current.rects.some(isNonZeroRect);
if (
hasRects &&
(!uniqueSuspendersOnly || current.hasUniqueSuspenders) &&
// Roots are already included as part of the Screen
current.id !== rootID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
}

let strictModeBadge = null;
if (element.isStrictModeNonCompliant) {
if (element.isStrictModeNonCompliant && element.parentID !== 0) {
strictModeBadge = (
<Tooltip label="This component is not running in StrictMode. Click to learn more.">
<a
Expand Down Expand Up @@ -237,7 +237,7 @@ export default function InspectedElementWrapper(_: Props): React.Node {
<div className={styles.SelectedComponentName}>
<div
className={
element.isStrictModeNonCompliant
element.isStrictModeNonCompliant && element.parentID !== 0
? `${styles.ComponentName} ${styles.StrictModeNonCompliantComponentName}`
: styles.ComponentName
}
Expand Down
Loading
Loading