Skip to content

Commit 46e3594

Browse files
authored
Merge branch 'main' into push-rpnlzllzpywq
2 parents bc32214 + 64becd0 commit 46e3594

15 files changed

Lines changed: 144 additions & 194 deletions

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@
134134
"@types/react-transition-group": "^4.4.5",
135135
"@types/redux-logger": "^3.0.6",
136136
"@types/tgwf__co2": "^0.14.2",
137-
"@typescript-eslint/eslint-plugin": "^8.56.0",
138-
"@typescript-eslint/parser": "^8.56.0",
137+
"@typescript-eslint/eslint-plugin": "^8.58.0",
138+
"@typescript-eslint/parser": "^8.58.0",
139139
"alex": "^11.0.1",
140140
"babel-jest": "^30.2.0",
141141
"babel-plugin-module-resolver": "^5.0.2",
@@ -177,7 +177,7 @@
177177
"stylelint-config-idiomatic-order": "^10.0.0",
178178
"stylelint-config-standard": "^40.0.0",
179179
"typescript": "^6.0.2",
180-
"typescript-eslint": "^8.56.0",
180+
"typescript-eslint": "^8.58.0",
181181
"workbox-cli": "^7.4.0",
182182
"yargs": "^18.0.0"
183183
},

src/app-logic/url-handling.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ export function getQueryStringFromUrlState(urlState: UrlState): string {
309309
: urlState.profileSpecific.implementation,
310310
timelineType:
311311
// The default is the cpu-category view, so only add it to the URL if it's
312-
// the stack or category view.
312+
// the stack view.
313313
urlState.profileSpecific.timelineType === 'cpu-category'
314314
? undefined
315315
: urlState.profileSpecific.timelineType,
@@ -1445,14 +1445,10 @@ function getVersion4JSCallNodePathFromStackIndex(
14451445
function validateTimelineType(
14461446
timelineType: string | null | undefined
14471447
): TimelineType {
1448-
const VALID_TIMELINE_TYPES: Record<TimelineType, true> = {
1449-
stack: true,
1450-
category: true,
1451-
'cpu-category': true,
1452-
};
1453-
if (timelineType && timelineType in VALID_TIMELINE_TYPES) {
1454-
return timelineType as TimelineType;
1448+
if (timelineType === 'stack') {
1449+
return 'stack';
14551450
}
1451+
// 'category' is an old value that is treated as 'cpu-category'.
14561452
return 'cpu-category';
14571453
}
14581454

src/components/shared/SourceView-codemirror.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121
import { EditorView, lineNumbers } from '@codemirror/view';
2222
import { EditorState, Compartment } from '@codemirror/state';
23-
import { syntaxHighlighting } from '@codemirror/language';
23+
import { type LanguageSupport, syntaxHighlighting } from '@codemirror/language';
2424
import { classHighlighter } from '@lezer/highlight';
2525
import { cpp } from '@codemirror/lang-cpp';
2626
import { rust } from '@codemirror/lang-rust';
@@ -46,9 +46,7 @@ const highlightedLineConf = new Compartment();
4646
const lineNumbersConf = new Compartment();
4747

4848
// Detect the right language based on the file extension.
49-
function _languageExtForPath(
50-
path: string | null
51-
): any /* LanguageSupport | [] */ {
49+
function _languageExtForPath(path: string | null): LanguageSupport | [] {
5250
if (path === null) {
5351
return [];
5452
}
@@ -77,7 +75,11 @@ function _languageExtForPath(
7775
) {
7876
return cpp();
7977
}
80-
return [];
78+
79+
// Fallback to JavaScript highlighting. Inline scripts share the page URL, so
80+
// their path won't have a .js extension. This may be incorrect for
81+
// unknown/unsupported file types, but is the best guess for the common case.
82+
return javascript();
8183
}
8284

8385
// Adjustments to make a CodeMirror editor work as a non-editable code viewer.

src/components/shared/thread/ActivityGraph.tsx

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import type {
2323
IndexIntoSamplesTable,
2424
Milliseconds,
2525
CssPixels,
26-
TimelineType,
2726
} from 'firefox-profiler/types';
2827
import type {
2928
ActivityFillGraphQuerier,
@@ -49,9 +48,7 @@ export type Props = {
4948
a: IndexIntoSamplesTable,
5049
b: IndexIntoSamplesTable
5150
) => number;
52-
readonly enableCPUUsage: boolean;
5351
readonly implementationFilter: ImplementationFilter;
54-
readonly timelineType: TimelineType;
5552
readonly zeroAt: Milliseconds;
5653
readonly profileTimelineUnit: string;
5754
} & SizeProps;
@@ -136,11 +133,9 @@ class ThreadActivityGraphImpl extends React.PureComponent<Props, State> {
136133
sampleIndexOffset,
137134
sampleSelectedStates,
138135
treeOrderSampleComparator,
139-
enableCPUUsage,
140136
implementationFilter,
141137
width,
142138
height,
143-
timelineType,
144139
zeroAt,
145140
profileTimelineUnit,
146141
} = this.props;
@@ -168,19 +163,14 @@ class ThreadActivityGraphImpl extends React.PureComponent<Props, State> {
168163
categories={categories}
169164
passFillsQuerier={this._setFillsQuerier}
170165
onClick={this._onClick}
171-
enableCPUUsage={enableCPUUsage}
172166
width={width}
173167
height={height}
174168
/>
175169
{hoveredPixelState === null ? null : (
176170
<Tooltip mouseX={mouseX} mouseY={mouseY}>
177171
<SampleTooltipContents
178172
sampleIndex={hoveredPixelState.sample}
179-
cpuRatioInTimeRange={
180-
timelineType === 'cpu-category'
181-
? hoveredPixelState.cpuRatioInTimeRange
182-
: null
183-
}
173+
cpuRatioInTimeRange={hoveredPixelState.cpuRatioInTimeRange}
184174
rangeFilteredThread={rangeFilteredThread}
185175
categories={categories}
186176
implementationFilter={implementationFilter}

src/components/shared/thread/ActivityGraphCanvas.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ type CanvasProps = {
3737
readonly categories: CategoryList;
3838
readonly passFillsQuerier: (param: ActivityFillGraphQuerier) => void;
3939
readonly onClick: (param: React.MouseEvent<HTMLCanvasElement>) => void;
40-
readonly enableCPUUsage: boolean;
4140
} & SizeProps;
4241

4342
export class ActivityGraphCanvas extends React.PureComponent<CanvasProps> {
@@ -132,7 +131,6 @@ export class ActivityGraphCanvas extends React.PureComponent<CanvasProps> {
132131
sampleIndexOffset,
133132
sampleSelectedStates,
134133
treeOrderSampleComparator,
135-
enableCPUUsage,
136134
width,
137135
height,
138136
} = this.props;
@@ -153,7 +151,6 @@ export class ActivityGraphCanvas extends React.PureComponent<CanvasProps> {
153151
rangeEnd,
154152
sampleIndexOffset,
155153
sampleSelectedStates,
156-
enableCPUUsage,
157154
xPixelsPerMs: canvasPixelWidth / (rangeEnd - rangeStart),
158155
treeOrderSampleComparator,
159156
categoryDrawStyles: this._getCategoryDrawStyles(ctx!),

src/components/shared/thread/ActivityGraphFills.tsx

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ type RenderedComponentSettings = {
3636
readonly rangeEnd: Milliseconds;
3737
readonly sampleIndexOffset: number;
3838
readonly xPixelsPerMs: number;
39-
readonly enableCPUUsage: boolean;
4039
readonly treeOrderSampleComparator:
4140
| ((a: IndexIntoSamplesTable, b: IndexIntoSamplesTable) => number)
4241
| null;
@@ -215,7 +214,6 @@ export class ActivityGraphFillComputer {
215214
fullThread,
216215
rangeFilteredThread: { samples },
217216
interval,
218-
enableCPUUsage,
219217
sampleIndexOffset,
220218
rangeStart,
221219
sampleSelectedStates,
@@ -243,12 +241,8 @@ export class ActivityGraphFillComputer {
243241
const nextSampleTime = samples.time[i + 1];
244242
const category = samples.category[i];
245243

246-
let beforeSampleCpuPercent = 100;
247-
let afterSampleCpuPercent = 100;
248-
if (enableCPUUsage) {
249-
beforeSampleCpuPercent = threadCPUPercent[i];
250-
afterSampleCpuPercent = threadCPUPercent[i + 1];
251-
}
244+
const beforeSampleCpuPercent = threadCPUPercent[i];
245+
const afterSampleCpuPercent = threadCPUPercent[i + 1];
252246

253247
const percentageBuffers = this.mutablePercentageBuffers[category];
254248
const selectedState = sampleSelectedStates[i];
@@ -273,12 +267,8 @@ export class ActivityGraphFillComputer {
273267
const lastIdx = samples.length - 1;
274268
const lastSampleCategory = samples.category[lastIdx];
275269

276-
let beforeSampleCpuPercent = 100;
277-
let afterSampleCpuPercent = 100;
278-
if (enableCPUUsage) {
279-
beforeSampleCpuPercent = threadCPUPercent[lastIdx];
280-
afterSampleCpuPercent = threadCPUPercent[lastIdx + 1]; // guaranteed to exist
281-
}
270+
const beforeSampleCpuPercent = threadCPUPercent[lastIdx];
271+
const afterSampleCpuPercent = threadCPUPercent[lastIdx + 1]; // guaranteed to exist
282272

283273
const nextSampleTime = sampleTime + interval;
284274
const percentageBuffers = this.mutablePercentageBuffers[lastSampleCategory];
@@ -596,7 +586,6 @@ export class ActivityFillGraphQuerier {
596586
): number {
597587
const {
598588
rangeFilteredThread: { samples },
599-
enableCPUUsage,
600589
interval,
601590
sampleIndexOffset,
602591
fullThread,
@@ -617,13 +606,9 @@ export class ActivityFillGraphQuerier {
617606
? fullThread.samples.time[fullThreadSample + 1]
618607
: sampleTime + interval;
619608

620-
let beforeSampleCpuPercent = 100;
621-
let afterSampleCpuPercent = 100;
622609
const { threadCPUPercent } = samples;
623-
if (enableCPUUsage) {
624-
beforeSampleCpuPercent = threadCPUPercent[sample];
625-
afterSampleCpuPercent = threadCPUPercent[sample + 1]; // guaranteed to exist
626-
}
610+
const beforeSampleCpuPercent = threadCPUPercent[sample];
611+
const afterSampleCpuPercent = threadCPUPercent[sample + 1]; // guaranteed to exist
627612

628613
const kernelRangeStartTime = rangeStart + kernelPos / xPixelsPerMs;
629614

src/components/shared/thread/SampleGraph.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,14 @@ import type {
2525
IndexIntoSamplesTable,
2626
Milliseconds,
2727
CssPixels,
28-
TimelineType,
2928
ImplementationFilter,
3029
} from 'firefox-profiler/types';
3130
import { SelectedState } from 'firefox-profiler/types';
3231
import type { SizeProps } from 'firefox-profiler/components/shared/WithSize';
33-
import type { CpuRatioInTimeRange } from './ActivityGraphFills';
3432
import { lightDark } from 'firefox-profiler/utils/dark-mode';
3533

3634
export type HoveredPixelState = {
3735
readonly sample: IndexIntoSamplesTable | null;
38-
readonly cpuRatioInTimeRange: CpuRatioInTimeRange | null;
3936
};
4037

4138
type Props = {
@@ -51,7 +48,6 @@ type Props = {
5148
sampleIndex: IndexIntoSamplesTable | null
5249
) => void;
5350
readonly trackName: string;
54-
readonly timelineType: TimelineType;
5551
readonly implementationFilter: ImplementationFilter;
5652
readonly zeroAt: Milliseconds;
5753
readonly profileTimelineUnit: string;
@@ -252,7 +248,7 @@ class ThreadSampleGraphCanvas extends React.PureComponent<CanvasProps> {
252248
}
253249

254250
export class ThreadSampleGraphImpl extends PureComponent<Props, State> {
255-
override state = {
251+
override state: State = {
256252
hoveredPixelState: null,
257253
mouseX: 0,
258254
mouseY: 0,
@@ -333,15 +329,13 @@ export class ThreadSampleGraphImpl extends PureComponent<Props, State> {
333329

334330
return {
335331
sample: sampleIndex,
336-
cpuRatioInTimeRange: null,
337332
};
338333
}
339334

340335
override render() {
341336
const {
342337
className,
343338
trackName,
344-
timelineType,
345339
categories,
346340
implementationFilter,
347341
thread,
@@ -379,12 +373,8 @@ export class ThreadSampleGraphImpl extends PureComponent<Props, State> {
379373
{hoveredPixelState === null ? null : (
380374
<Tooltip mouseX={mouseX} mouseY={mouseY}>
381375
<SampleTooltipContents
382-
sampleIndex={(hoveredPixelState as HoveredPixelState).sample}
383-
cpuRatioInTimeRange={
384-
timelineType === 'cpu-category'
385-
? (hoveredPixelState as HoveredPixelState).cpuRatioInTimeRange
386-
: null
387-
}
376+
sampleIndex={hoveredPixelState.sample}
377+
cpuRatioInTimeRange={null}
388378
rangeFilteredThread={thread}
389379
categories={categories}
390380
implementationFilter={implementationFilter}

src/components/timeline/TrackThread.tsx

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ type StateProps = {
8787
b: IndexIntoSamplesTable
8888
) => number;
8989
readonly selectedThreadIndexes: Set<ThreadIndex>;
90-
readonly enableCPUUsage: boolean;
9190
readonly isExperimentalCPUGraphsEnabled: boolean;
9291
readonly implementationFilter: ImplementationFilter;
9392
readonly callTreeVisible: boolean;
@@ -186,7 +185,6 @@ class TimelineTrackThreadImpl extends PureComponent<Props> {
186185
treeOrderSampleComparator,
187186
trackType,
188187
trackName,
189-
enableCPUUsage,
190188
isExperimentalCPUGraphsEnabled,
191189
implementationFilter,
192190
zeroAt,
@@ -241,8 +239,7 @@ class TimelineTrackThreadImpl extends PureComponent<Props> {
241239
/>
242240
) : null}
243241

244-
{(timelineType === 'category' || timelineType === 'cpu-category') &&
245-
!filteredThread.isJsTracer ? (
242+
{timelineType !== 'stack' && !filteredThread.isJsTracer ? (
246243
<>
247244
<ThreadActivityGraph
248245
className="threadActivityGraph"
@@ -257,9 +254,7 @@ class TimelineTrackThreadImpl extends PureComponent<Props> {
257254
categories={categories}
258255
sampleSelectedStates={sampleSelectedStates}
259256
treeOrderSampleComparator={treeOrderSampleComparator}
260-
enableCPUUsage={enableCPUUsage}
261257
implementationFilter={implementationFilter}
262-
timelineType={timelineType}
263258
zeroAt={zeroAt}
264259
profileTimelineUnit={profileTimelineUnit}
265260
/>
@@ -274,7 +269,6 @@ class TimelineTrackThreadImpl extends PureComponent<Props> {
274269
sampleSelectedStates={sampleSelectedStates}
275270
categories={categories}
276271
onSampleClick={this._onSampleClick}
277-
timelineType={timelineType}
278272
implementationFilter={implementationFilter}
279273
zeroAt={zeroAt}
280274
profileTimelineUnit={profileTimelineUnit}
@@ -335,8 +329,6 @@ export const TimelineTrackThread = explicitConnect<
335329
const committedRange = getCommittedRange(state);
336330
const fullThread = selectors.getThread(state);
337331
const timelineType = getTimelineType(state);
338-
const enableCPUUsage =
339-
timelineType === 'cpu-category' && fullThread.samples.hasCPUDeltas;
340332

341333
return {
342334
fullThread,
@@ -361,7 +353,6 @@ export const TimelineTrackThread = explicitConnect<
361353
treeOrderSampleComparator:
362354
selectors.getTreeOrderComparatorInFilteredThread(state),
363355
selectedThreadIndexes,
364-
enableCPUUsage,
365356
isExperimentalCPUGraphsEnabled: getIsExperimentalCPUGraphsEnabled(state),
366357
implementationFilter: getImplementationFilter(state),
367358
callTreeVisible: selectors.getUsefulTabs(state).includes('calltree'),

src/profile-logic/profile-data.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4305,10 +4305,8 @@ export function getNativeSymbolInfo(
43054305
/**
43064306
* Determines the timeline type by looking at the profile data.
43074307
*
4308-
* There are three options:
4309-
* 'cpu-category': If a profile has both category and cpu usage information.
4310-
* 'category': If a profile has category information but not the cpu usage.
4311-
* 'stack': If a profile doesn't have category or cpu usage information.
4308+
* 'cpu-category': If a profile has category information.
4309+
* 'stack': If a profile doesn't have category information.
43124310
*/
43134311
export function determineTimelineType(profile: Profile): TimelineType {
43144312
if (!profile.meta.categories) {
@@ -4318,16 +4316,6 @@ export function determineTimelineType(profile: Profile): TimelineType {
43184316
return 'stack';
43194317
}
43204318

4321-
if (
4322-
!profile.meta.sampleUnits ||
4323-
!profile.threads.some((thread) => thread.samples.threadCPUDelta)
4324-
) {
4325-
// Have category information but doesn't have the CPU usage information.
4326-
// Use 'category'.
4327-
return 'category';
4328-
}
4329-
4330-
// Have both category and CPU usage information. Use 'cpu-category'.
43314319
return 'cpu-category';
43324320
}
43334321

src/test/store/profile-view.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3869,12 +3869,14 @@ describe('timeline type', function () {
38693869
);
38703870
});
38713871

3872-
it('should use the category view when cpu is not provided', () => {
3872+
it('should use the cpu-category view even if no cpu is provided', () => {
38733873
const { profile } = getProfileFromTextSamples('A');
38743874

38753875
// Load the store after mutating the profile.
38763876
const { getState } = storeWithProfile(profile);
3877-
expect(UrlStateSelectors.getTimelineType(getState())).toEqual('category');
3877+
expect(UrlStateSelectors.getTimelineType(getState())).toEqual(
3878+
'cpu-category'
3879+
);
38783880
});
38793881

38803882
it('should use the stack height view when category and cpu is not provided', () => {

0 commit comments

Comments
 (0)