Skip to content
Open
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
6 changes: 5 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ module.exports = {
'!src/types/libdef/**',
],

transform: {
'\\.([jt]sx?|mjs)$': 'babel-jest',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it would be good to add a comment here saying that \\.[jt]sx?$ is the default regexp and we change it to make sure that mjs files are included.

},

// Transform ESM modules to CommonJS for Jest
// These packages ship as pure ESM and need to be transformed by Babel
transformIgnorePatterns: [
'/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock)/)',
'/node_modules/(?!(query-string|decode-uri-component|iongraph-web|split-on-first|filter-obj|fetch-mock|devtools-reps)/)',
],

// Mock static assets (images, CSS, etc.)
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
"common-tags": "^1.8.2",
"copy-to-clipboard": "^3.3.3",
"core-js": "^3.47.0",
"devtools-reps": "^0.27.3",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like 0.27.4 is out now. I don't know if you need it or if it's crucial. Otherwise our dependency updates will handle it.

"escape-string-regexp": "^4.0.0",
"gecko-profiler-demangle": "^0.4.0",
"idb": "^8.0.3",
Expand Down
14 changes: 14 additions & 0 deletions res/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,17 @@
.colored-border.ellipsis {
opacity: 0;
}

/* Colors for DevTools Reps */
:root {
--number-color: #058b00;
--string-color: #dd00a9;
--null-color: #5c5c5f;
--object-color: #0074e8;
--caption-color: #0074e8;
--location-color: #5c5c5f;
--source-link-color: #0060df;
--node-color: #003eaa;
--reference-color: #0074e8;
--comment-node-color: #5c5c5f;
Comment on lines +35 to +44
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they the variables used inside reps css file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are - do you have a suggestion on where they should live, if you'd like them to live elsewhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine for them to live there. From the package devtools-reps perspective maybe it would be better to have a prefix in their name to make sure that they don't clash with other variables (like --reps-number-color etc.). But since devtools-reps is published already I don't think it's something we should change right away. It might be good to file a bug in the devtools side though. cc @ochameau

}
13 changes: 13 additions & 0 deletions src/components/stack-chart/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import type {

type ChangeMouseTimePosition = typeof changeMouseTimePosition;
import { mapCategoryColorNameToStackChartStyles } from '../../utils/colors';
import { ValueSummaryReader } from 'devtools-reps';
import { TooltipCallNode } from '../tooltip/CallNode';
import { TooltipMarker } from '../tooltip/Marker';

Expand Down Expand Up @@ -624,6 +625,17 @@ class StackChartCanvasImpl extends React.PureComponent<Props> {
timelineUnit === 'bytes'
? formatBytes(duration)
: formatMilliseconds(duration);
let argumentSummaries = undefined;
if (timing.argumentValues) {
const argumentValues = timing.argumentValues[stackTimingIndex];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The argumentValues variable is really a argumentValuesIndex right? Could we maybe rename it to be clearer?

if (argumentValues !== -1) {
argumentSummaries = ValueSummaryReader.getArgumentSummaries(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm typescript says the return value of ValueSummaryReader.getArgumentSummaries is any which isn't very helpful. Do you know what it returns? I see Array<object> below, I would say that it's better than any. Ideally it would be good to type them.

thread.tracedValuesBuffer as ArrayBuffer,
thread.tracedObjectShapes as Array<string[] | null>,
Comment on lines +633 to +634
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove these casts by checking if they are present in the if check above?

if (timing.argumentValues) {

Could be updated to cover these:

 if (timing.argumentValues && thread.tracedValuesBuffer && thread.tracedObjectShapes) {

Technically if argumentValues is present the others should be too, but it's good to be a bit more defensive and avoid an explicit cast.

argumentValues
);
}
}

return (
<TooltipCallNode
Expand All @@ -638,6 +650,7 @@ class StackChartCanvasImpl extends React.PureComponent<Props> {
callTreeSummaryStrategy="timing"
durationText={durationText}
displayStackType={displayStackType}
argumentValues={argumentSummaries}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to be consistent with the naming here. Either we should use argumentValues or argumentSummaries. I'm leaning towards argumentSummaries since this is the return value of getArgumentSummaries

/>
);
};
Expand Down
28 changes: 28 additions & 0 deletions src/components/tooltip/CallNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ import type {
OneCategoryBreakdown,
} from 'firefox-profiler/profile-logic/profile-data';
import type { CallNodeInfo } from 'firefox-profiler/profile-logic/call-node-info';
import { REPS, MODE } from 'devtools-reps';
const { Rep } = REPS;

import './CallNode.css';
import classNames from 'classnames';
Expand Down Expand Up @@ -129,6 +131,7 @@ type Props = {
readonly timings?: TimingsForPath;
readonly callTreeSummaryStrategy: CallTreeSummaryStrategy;
readonly displayStackType: boolean;
readonly argumentValues?: Array<object>;
};

/**
Expand Down Expand Up @@ -358,6 +361,7 @@ export class TooltipCallNode extends React.PureComponent<Props> {
thread,
durationText,
categories,
argumentValues,
displayData,
timings,
callTreeSummaryStrategy,
Expand Down Expand Up @@ -426,6 +430,29 @@ export class TooltipCallNode extends React.PureComponent<Props> {
];
}

let argumentsElement = null;
if (argumentValues) {
if (argumentValues.length === 0) {
argumentsElement = <div className="arguments">No arguments.</div>;
} else {
const argumentValuesEl = [];
for (const previewObject of argumentValues) {
argumentValuesEl.push(
Rep({
object: previewObject,
mode: MODE.LONG,
})
);
}
argumentsElement = (
<div className="arguments">
<div className="argumentsLabel">Arguments</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: to make it similar to the other fields:

Suggested change
<div className="argumentsLabel">Arguments</div>
<div className="argumentsLabel">Arguments:</div>

can we also switch arguments and argumentsLabel classes to tooltipArguments and tooltipArgumentsLabel here and in the css?

And looking at the tooltip, the arguments class needs the same padding as the other tooltip content I think so it looks more unified. We have this for the rest of the tooltip:

padding: 10px;
padding-bottom: 5px;

tip: you can call window.persistTooltips = true in the console to make them sticky while working on them.

{argumentValuesEl}
</div>
);
}
}

// Finding current frame and parent frame URL(if there is).
let pageAndParentPageURL;
if (innerWindowIDToPageMap) {
Expand Down Expand Up @@ -542,6 +569,7 @@ export class TooltipCallNode extends React.PureComponent<Props> {
{resource}
</div>
{this._renderCategoryTimings(timings)}
{argumentsElement}
</div>
</div>
);
Expand Down
14 changes: 14 additions & 0 deletions src/components/tooltip/Tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,17 @@
.sidebar .tooltipDetailSeparator {
display: none;
}

.argumentsLabel {
/* match tooltips label, without being aligned to the right */
color: var(--grey-50);
}

.arguments > span {
display: block;
padding: 0.25em;
}

.arguments > span:nth-child(odd) {
background-color: rgb(0 0 0 / 0.05);
}
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../res/css/global.css';
import '../res/css/categories.css';
import '../res/css/network.css';
import 'react-splitter-layout/lib/index.css';
import 'devtools-reps/reps.css';

// React imported for JSX in Root component
import { createRoot } from 'react-dom/client';
Expand Down
12 changes: 12 additions & 0 deletions src/profile-logic/process-profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,10 @@ function _processSamples(geckoSamples: GeckoSampleStruct): RawSamplesTable {
}
}

if ('argumentValues' in geckoSamples) {
samples.argumentValues = geckoSamples.argumentValues;
}

if ('eventDelay' in geckoSamples) {
samples.eventDelay = geckoSamples.eventDelay;
} else if ('responsiveness' in geckoSamples) {
Expand Down Expand Up @@ -1251,6 +1255,14 @@ function _processThread(
newThread.nativeAllocations = nativeAllocations;
}

if (thread.tracedValues) {
newThread.tracedValuesBuffer = thread.tracedValues;
}

if (thread.tracedObjectShapes) {
newThread.tracedObjectShapes = thread.tracedObjectShapes;
}

function processJsTracer() {
// Optionally extract the JS Tracer information, if they exist.
const { jsTracerEvents } = thread;
Expand Down
25 changes: 24 additions & 1 deletion src/profile-logic/profile-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1732,6 +1732,13 @@ export function filterThreadSamplesToRange(
);
}

if (samples.argumentValues) {
newSamples.argumentValues = samples.argumentValues.slice(
beginSampleIndex,
endSampleIndex
);
}

if (samples.threadId) {
newSamples.threadId = samples.threadId.slice(
beginSampleIndex,
Expand Down Expand Up @@ -1858,6 +1865,13 @@ export function filterRawThreadSamplesToRange(
);
}

if (samples.argumentValues) {
newSamples.argumentValues = samples.argumentValues.slice(
beginSampleIndex,
endSampleIndex
);
}

if (samples.threadId) {
newSamples.threadId = samples.threadId.slice(
beginSampleIndex,
Expand Down Expand Up @@ -1964,6 +1978,9 @@ export function filterCounterSamplesToRange(
number: samples.number
? samples.number.slice(beginSampleIndex, endSampleIndex)
: undefined,
argumentValues: samples.argumentValues
? samples.argumentValues.slice(beginSampleIndex, endSampleIndex)
: undefined,
};

return newCounter;
Expand Down Expand Up @@ -2288,6 +2305,7 @@ export function computeSamplesTableFromRawSamplesTable(
const {
responsiveness,
eventDelay,
argumentValues,
stack,
weight,
weightType,
Expand All @@ -2309,6 +2327,7 @@ export function computeSamplesTableFromRawSamplesTable(
// These fields are copied from the raw samples table:
responsiveness,
eventDelay,
argumentValues,
stack,
weight,
weightType,
Expand All @@ -2329,7 +2348,8 @@ export function createThreadFromDerivedTables(
samples: SamplesTable,
stackTable: StackTable,
stringTable: StringTable,
sources: SourceTable
sources: SourceTable,
tracedValuesBuffer: ArrayBuffer | undefined
): Thread {
const {
processType,
Expand All @@ -2356,6 +2376,7 @@ export function createThreadFromDerivedTables(
jsTracer,
isPrivateBrowsing,
userContextId,
tracedObjectShapes,
} = rawThread;

const thread: Thread = {
Expand Down Expand Up @@ -2384,12 +2405,14 @@ export function createThreadFromDerivedTables(
jsTracer,
isPrivateBrowsing,
userContextId,
tracedObjectShapes,

// These fields are derived:
samples,
stackTable,
stringTable,
sources,
tracedValuesBuffer,
};
return thread;
}
Expand Down
46 changes: 38 additions & 8 deletions src/profile-logic/stack-timing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export type StackTiming = {
sameWidthsStart: number[];
sameWidthsEnd: number[];
callNode: IndexIntoCallNodeTable[];
argumentValues?: number[];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could you add a comment explaining that this is used for JS execution tracing argument values?

length: number;
};

Expand Down Expand Up @@ -115,14 +116,20 @@ export function getStackTimingByDepth(
} = callNodeTable;
const stackTimingByDepth: StackTimingByDepth = Array.from(
{ length: maxDepthPlusOne },
(): StackTiming => ({
start: [],
end: [],
sameWidthsStart: [],
sameWidthsEnd: [],
callNode: [],
length: 0,
})
(): StackTiming => {
const shape: StackTiming = {
start: [],
end: [],
sameWidthsStart: [],
sameWidthsEnd: [],
callNode: [],
length: 0,
};
if ('argumentValues' in samples) {
shape.argumentValues = [];
}
return shape;
}
);

const sameWidthsIndexToTimestampMap: SameWidthsIndexToTimestampMap = [];
Expand Down Expand Up @@ -154,6 +161,7 @@ export function getStackTimingByDepth(
let deepestOpenBoxDepth = -1;
const openBoxStartTimeByDepth = new Float64Array(maxDepthPlusOne);
const openBoxStartTickByDepth = new Float64Array(maxDepthPlusOne);
const openBoxArgsByDepth = new Int32Array(maxDepthPlusOne);

let currentStackTick = 0;
for (let sampleIndex = 0; sampleIndex < samples.length; sampleIndex++) {
Expand All @@ -162,6 +170,14 @@ export function getStackTimingByDepth(
continue;
}

let sampleArgs: number = -1;
if ('argumentValues' in samples && samples.argumentValues !== undefined) {
const val = samples.argumentValues[sampleIndex];
if (val !== null) {
sampleArgs = val;
}
}

const sampleTime = samples.time[sampleIndex];

// Phase 1: Commit open boxes which are not shared by the current call node,
Expand Down Expand Up @@ -193,6 +209,10 @@ export function getStackTimingByDepth(
stackTimingForThisDepth.sameWidthsStart[index] = startStackTick;
stackTimingForThisDepth.sameWidthsEnd[index] = currentStackTick;
stackTimingForThisDepth.callNode[index] = deepestOpenBoxCallNodeIndex;
if (stackTimingForThisDepth.argumentValues) {
stackTimingForThisDepth.argumentValues[index] =
openBoxArgsByDepth[deepestOpenBoxDepth];
}
deepestOpenBoxCallNodeIndex =
callNodeTablePrefixColumn[deepestOpenBoxCallNodeIndex];
deepestOpenBoxDepth--;
Expand All @@ -208,6 +228,12 @@ export function getStackTimingByDepth(
deepestOpenBoxDepth++;
openBoxStartTimeByDepth[deepestOpenBoxDepth] = sampleTime;
openBoxStartTickByDepth[deepestOpenBoxDepth] = currentStackTick;
if (
'argumentValues' in samples &&
samples.argumentValues !== undefined
) {
openBoxArgsByDepth[deepestOpenBoxDepth] = sampleArgs;
}
}
}

Expand All @@ -229,6 +255,10 @@ export function getStackTimingByDepth(
stackTimingForThisDepth.sameWidthsStart[index] = startStackTick;
stackTimingForThisDepth.sameWidthsEnd[index] = currentStackTick;
stackTimingForThisDepth.callNode[index] = deepestOpenBoxCallNodeIndex;
if (stackTimingForThisDepth.argumentValues) {
stackTimingForThisDepth.argumentValues[index] =
openBoxArgsByDepth[deepestOpenBoxDepth];
}
deepestOpenBoxCallNodeIndex =
callNodeTablePrefixColumn[deepestOpenBoxCallNodeIndex];
deepestOpenBoxDepth--;
Expand Down
Loading