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

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 @@ -18,10 +18,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 @@ -82,6 +82,7 @@
"common-tags": "^1.8.2",
"copy-to-clipboard": "^3.3.3",
"core-js": "^3.47.0",
"devtools-reps": "^0.27.3",
"escape-string-regexp": "^4.0.0",
"gecko-profiler-demangle": "^0.4.0",
"idb": "^8.0.3",
Expand Down
12 changes: 12 additions & 0 deletions res/css/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,18 @@
--wide-splitter-hover-color: #bbb;
--wide-splitter-pressed-color: #aaa;

/* Colors for DevTools Reps */
--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;

color: var(--base-foreground-color);
}

Expand Down
23 changes: 23 additions & 0 deletions src/components/stack-chart/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
getForegroundColor,
getBackgroundColor,
} from '../../utils/colors';
import { ValueSummaryReader } from 'devtools-reps';
import { TooltipCallNode } from '../tooltip/CallNode';
import { TooltipMarker } from '../tooltip/Marker';

Expand Down Expand Up @@ -623,6 +624,27 @@ class StackChartCanvasImpl extends React.PureComponent<Props> {
timelineUnit === 'bytes'
? formatBytes(duration)
: formatMilliseconds(duration);
let argumentSummaries = undefined;
if (timing.argumentValues) {
const argumentValuesIndex = timing.argumentValues[stackTimingIndex];
if (
argumentValuesIndex !== -1 &&
thread.tracedValuesBuffer &&
thread.tracedObjectShapes
) {
const argSummaries = ValueSummaryReader.getArgumentSummaries(
thread.tracedValuesBuffer,
thread.tracedObjectShapes,
argumentValuesIndex
);
// The API maybe needs work - getArgumentSummaries can return a string indicating
// that the argument summaries for a given call were missing (this can happen if they
// were overwritten in the underlying ring buffer)
if (typeof argSummaries !== 'string') {
argumentSummaries = argSummaries;
}
}
}

return (
<TooltipCallNode
Expand All @@ -637,6 +659,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
32 changes: 32 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,33 @@ export class TooltipCallNode extends React.PureComponent<Props> {
];
}

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

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

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

.tooltipArguments > span {
display: block;
}

.tooltipArguments > span:nth-child(odd) {
background-color: rgb(0 0 0 / 0.05);
}

.tooltipArguments {
text-indent: 1em hanging;
}
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 @@ -1015,6 +1015,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 @@ -1255,6 +1259,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 @@ -1882,6 +1882,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 @@ -2008,6 +2015,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 @@ -2114,6 +2128,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 @@ -2438,6 +2455,7 @@ export function computeSamplesTableFromRawSamplesTable(
const {
responsiveness,
eventDelay,
argumentValues,
stack,
weight,
weightType,
Expand All @@ -2459,6 +2477,7 @@ export function computeSamplesTableFromRawSamplesTable(
// These fields are copied from the raw samples table:
responsiveness,
eventDelay,
argumentValues,
stack,
weight,
weightType,
Expand All @@ -2479,7 +2498,8 @@ export function createThreadFromDerivedTables(
samples: SamplesTable,
stackTable: StackTable,
stringTable: StringTable,
sources: SourceTable
sources: SourceTable,
tracedValuesBuffer: ArrayBuffer | undefined
): Thread {
const {
processType,
Expand All @@ -2506,6 +2526,7 @@ export function createThreadFromDerivedTables(
jsTracer,
isPrivateBrowsing,
userContextId,
tracedObjectShapes,
} = rawThread;

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

// These fields are derived:
samples,
stackTable,
stringTable,
sources,
tracedValuesBuffer,
};
return thread;
}
Expand Down
3 changes: 3 additions & 0 deletions src/profile-logic/sanitize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,9 @@ function sanitizeThreadPII(
delete newThread['eTLD+1'];
}

delete newThread.tracedValuesBuffer;
delete newThread.tracedObjectShapes;

if (windowIdFromPrivateBrowsing.size > 0) {
// In this block, we'll remove everything related to frame table entries
// that have a innerWindowID with a isPrivateBrowsing flag.
Expand Down
Loading