Skip to content

Commit 339452a

Browse files
authored
Merge branch 'main' into new-withchartviewport
2 parents b9d9eb6 + 55a1cc0 commit 339452a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1052
-487
lines changed

locales/en-US/app.ftl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,8 @@ ServiceWorkerManager--hide-notice-button =
786786

787787
StackSettings--implementation-all-frames = All frames
788788
.title = Do not filter the stack frames
789-
StackSettings--implementation-javascript2 = JavaScript
790-
.title = Show only the stack frames related to JavaScript execution
789+
StackSettings--implementation-script = Script
790+
.title = Show only the stack frames related to script execution
791791
StackSettings--implementation-native2 = Native
792792
.title = Show only the stack frames for native code
793793

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"test-coverage": "run-s test-build-coverage test-serve-coverage",
5555
"test-alex": "alex ./docs-* *.md",
5656
"test-lockfile": "lockfile-lint --path yarn.lock --allowed-hosts yarn --validate-https",
57-
"test-debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
57+
"test-debug": "cross-env LC_ALL=C TZ=UTC NODE_ENV=test node --inspect-brk node_modules/.bin/jest --runInBand",
5858
"postinstall": "patch-package"
5959
},
6060
"license": "MPL-2.0",

src/actions/profile-view.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export function selectSelfCallNode(
182182
// We're not calling callNodeInfo.getCallNodePathFromIndex here because we
183183
// only have a non-inverted call node index, which wouldn't be accepted by
184184
// the inverted call node info.
185-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
185+
const callNodeTable = callNodeInfo.getCallNodeTable();
186186
const callNodePath = [];
187187
let cni = nonInvertedSelfCallNode;
188188
while (cni !== -1) {
@@ -1951,7 +1951,7 @@ export function handleCallNodeTransformShortcut(
19511951
const funcIndex = callNodeInfo.funcForNode(callNodeIndex);
19521952
const category = callNodeInfo.categoryForNode(callNodeIndex);
19531953

1954-
const nonInvertedCallNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
1954+
const callNodeTable = callNodeInfo.getCallNodeTable();
19551955

19561956
switch (event.key) {
19571957
case 'F':
@@ -2010,7 +2010,7 @@ export function handleCallNodeTransformShortcut(
20102010
break;
20112011
}
20122012
case 'r': {
2013-
if (funcHasRecursiveCall(nonInvertedCallNodeTable, funcIndex)) {
2013+
if (funcHasRecursiveCall(callNodeTable, funcIndex)) {
20142014
dispatch(
20152015
addTransformToStack(threadsKey, {
20162016
type: 'collapse-recursion',
@@ -2021,7 +2021,7 @@ export function handleCallNodeTransformShortcut(
20212021
break;
20222022
}
20232023
case 'R': {
2024-
if (funcHasDirectRecursiveCall(nonInvertedCallNodeTable, funcIndex)) {
2024+
if (funcHasDirectRecursiveCall(callNodeTable, funcIndex)) {
20252025
dispatch(
20262026
addTransformToStack(threadsKey, {
20272027
type: 'collapse-direct-recursion',

src/components/app/Home.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ActionButtons extends React.PureComponent<
5454
ActionButtonsProps,
5555
ActionButtonsState,
5656
> {
57-
_fileInput: HTMLInputElement | null;
57+
_fileInput: HTMLInputElement | null = null;
5858

5959
state = {
6060
isLoadFromUrlPressed: false,

src/components/app/KeyboardShortcut.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,23 @@ export class KeyboardShortcut extends React.PureComponent<Props, State> {
5454
});
5555
}
5656

57-
_open = (state: State): $Shape<State> => {
57+
_open = (state: State): State => {
5858
if (state.isOpen) {
5959
// Do nothing.
60-
return {};
60+
return state;
6161
}
6262
const focusAfterClosed = document.activeElement;
6363
this._trapFocus();
6464
this._focus();
6565
return { isOpen: true, focusAfterClosed };
6666
};
6767

68-
_close = (state: State): $Shape<State> => {
68+
_close = (state: State): State => {
6969
const { focusAfterClosed, isOpen } = state;
7070

7171
if (!isOpen) {
7272
// Do nothing.
73-
return {};
73+
return state;
7474
}
7575
this._untrapFocus();
7676
if (focusAfterClosed) {

src/components/app/MenuButtons/Permalink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ type State = {|
2727
|};
2828

2929
export class MenuButtonsPermalink extends React.PureComponent<Props, State> {
30-
_permalinkTextField: HTMLInputElement | null;
30+
_permalinkTextField: HTMLInputElement | null = null;
3131
_takePermalinkTextFieldRef = (elem: HTMLInputElement | null) => {
3232
this._permalinkTextField = elem;
3333
};

src/components/flame-graph/Canvas.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class FlameGraphCanvasImpl extends React.PureComponent<Props> {
158158
return;
159159
}
160160

161-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
161+
const callNodeTable = callNodeInfo.getCallNodeTable();
162162
const depth = callNodeTable.depth[selectedCallNodeIndex];
163163
const y = (maxStackDepthPlusOne - depth - 1) * ROW_HEIGHT;
164164

@@ -232,7 +232,7 @@ class FlameGraphCanvasImpl extends React.PureComponent<Props> {
232232
fastFillStyle.set('#ffffff');
233233
ctx.fillRect(0, 0, deviceContainerWidth, deviceContainerHeight);
234234

235-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
235+
const callNodeTable = callNodeInfo.getCallNodeTable();
236236

237237
const startDepth = Math.floor(
238238
maxStackDepthPlusOne - viewportBottom / stackFrameHeight

src/components/flame-graph/FlameGraph.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
163163
_wideEnough = (callNodeIndex: IndexIntoCallNodeTable): boolean => {
164164
const { flameGraphTiming, callNodeInfo } = this.props;
165165

166-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
166+
const callNodeTable = callNodeInfo.getCallNodeTable();
167167
const depth = callNodeTable.depth[callNodeIndex];
168168
const row = flameGraphTiming[depth];
169169
const columnIndex = row.callNode.indexOf(callNodeIndex);
@@ -188,7 +188,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
188188

189189
let callNodeIndex = startingCallNodeIndex;
190190

191-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
191+
const callNodeTable = callNodeInfo.getCallNodeTable();
192192
const depth = callNodeTable.depth[callNodeIndex];
193193
const row = flameGraphTiming[depth];
194194
let columnIndex = row.callNode.indexOf(callNodeIndex);
@@ -219,7 +219,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
219219
changeSelectedCallNode,
220220
handleCallNodeTransformShortcut,
221221
} = this.props;
222-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
222+
const callNodeTable = callNodeInfo.getCallNodeTable();
223223

224224
if (
225225
// Please do not forget to update the switch/case below if changing the array to allow more keys.
@@ -305,7 +305,7 @@ class FlameGraphImpl extends React.PureComponent<Props> {
305305
if (document.activeElement === this._viewport) {
306306
event.preventDefault();
307307
const { callNodeInfo, selectedCallNodeIndex, thread } = this.props;
308-
const callNodeTable = callNodeInfo.getNonInvertedCallNodeTable();
308+
const callNodeTable = callNodeInfo.getCallNodeTable();
309309
if (selectedCallNodeIndex !== null) {
310310
const funcIndex = callNodeTable.func[selectedCallNodeIndex];
311311
const funcName = thread.stringTable.getString(

src/components/network-chart/NetworkChartRow.js

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ import {
1313
guessMimeTypeFromNetworkMarker,
1414
getColorClassNameForMimeType,
1515
} from '../../profile-logic/marker-data';
16+
import {
17+
getLatestPreconnectPhaseAndValue,
18+
getMatchingPhaseValues,
19+
} from '../../profile-logic/network';
1620
import { formatNumber } from '../../utils/format-numbers';
1721
import {
1822
TIMELINE_MARGIN_LEFT,
@@ -28,6 +32,7 @@ import type {
2832
Marker,
2933
MarkerIndex,
3034
NetworkPayload,
35+
NetworkPhaseName,
3136
MixedObject,
3237
} from 'firefox-profiler/types';
3338

@@ -65,14 +70,14 @@ const PATH_SPLIT_RE = /(.*)(\/[^/]+\/?)$/;
6570
// `endTime` is the timestamp when the response is delivered to the caller. It's
6671
// not present in this array as it's implicit in the component logic.
6772
// They may be all missing in a specific marker, that's fine.
68-
const PROPERTIES_IN_ORDER = [
73+
const PHASE_NAMES_IN_ORDER: NetworkPhaseName[] = [
6974
'domainLookupStart',
7075
'requestStart',
7176
'responseStart',
7277
'responseEnd',
7378
];
7479

75-
const PHASE_OPACITIES = PROPERTIES_IN_ORDER.reduce(
80+
const PHASE_OPACITIES = PHASE_NAMES_IN_ORDER.reduce(
7681
(result, property, i, { length }) => {
7782
result[property] = length > 1 ? i / (length - 1) : 0;
7883
return result;
@@ -81,8 +86,8 @@ const PHASE_OPACITIES = PROPERTIES_IN_ORDER.reduce(
8186
);
8287

8388
type NetworkPhaseProps = {|
84-
+name: string,
85-
+previousName: string,
89+
+name: NetworkPhaseName,
90+
+previousName: NetworkPhaseName,
8691
+value: number | string,
8792
+duration: Milliseconds,
8893
+style: MixedObject,
@@ -140,25 +145,6 @@ class NetworkChartRowBar extends React.PureComponent<NetworkChartRowBarProps> {
140145
return markerPosition;
141146
}
142147

143-
/**
144-
* Properties `connectEnd` and `domainLookupEnd` aren't always present. This
145-
* function returns the latest one so that we can determine if these phases
146-
* happen in a preconnect session.
147-
*/
148-
_getLatestPreconnectEndProperty(): 'connectEnd' | 'domainLookupEnd' | null {
149-
const { networkPayload } = this.props;
150-
151-
if (typeof networkPayload.connectEnd === 'number') {
152-
return 'connectEnd';
153-
}
154-
155-
if (typeof networkPayload.domainLookupEnd === 'number') {
156-
return 'domainLookupEnd';
157-
}
158-
159-
return null;
160-
}
161-
162148
/**
163149
* This returns the preconnect component, or null if there's no preconnect
164150
* operation for this marker.
@@ -175,15 +161,14 @@ class NetworkChartRowBar extends React.PureComponent<NetworkChartRowBarProps> {
175161
// The preconnect bar goes from the start to the end of the whole preconnect
176162
// operation, that includes both the domain lookup and the connection
177163
// process. Therefore we want the property that represents the latest phase.
178-
const latestPreconnectEndProperty = this._getLatestPreconnectEndProperty();
164+
const latestPreconnectEndProperty = getLatestPreconnectPhaseAndValue(
165+
this.props.networkPayload
166+
);
179167
if (!latestPreconnectEndProperty) {
180168
return null;
181169
}
182170

183-
// We force-coerce the value into a number just to appease Flow. Indeed
184-
// the previous find operation ensures that all values are numbers but
185-
// Flow can't know that.
186-
const preconnectEnd = +networkPayload[latestPreconnectEndProperty];
171+
const preconnectEnd = latestPreconnectEndProperty.value;
187172

188173
// If the latest phase ends before the start of the marker, we'll display a
189174
// separate preconnect bar.
@@ -201,7 +186,7 @@ class NetworkChartRowBar extends React.PureComponent<NetworkChartRowBarProps> {
201186
const preconnectWidth = preconnectEndPosition - preconnectStartPosition;
202187

203188
const preconnectPhase = {
204-
name: latestPreconnectEndProperty,
189+
name: latestPreconnectEndProperty.phase,
205190
previousName: 'domainLookupStart',
206191
value: preconnectEnd,
207192
duration: preconnectDuration,
@@ -243,42 +228,33 @@ class NetworkChartRowBar extends React.PureComponent<NetworkChartRowBarProps> {
243228
const preconnectComponent = this._preconnectComponent();
244229

245230
// Compute the phases for this marker.
246-
247-
// If there's a preconnect phase, we remove `domainLookupStart` from the
248-
// main bar, but we'll draw a separate bar to represent it.
249-
const mainBarProperties = preconnectComponent
250-
? PROPERTIES_IN_ORDER.slice(1)
251-
: PROPERTIES_IN_ORDER;
252-
253-
// Not all properties are always present.
254-
const availableProperties = mainBarProperties.filter(
255-
(property) => typeof networkPayload[property] === 'number'
231+
const availablePhases = getMatchingPhaseValues(
232+
networkPayload,
233+
// If there's a preconnect phase, we remove `domainLookupStart` from the
234+
// main bar, but we'll draw a separate bar to represent it.
235+
preconnectComponent ? PHASE_NAMES_IN_ORDER.slice(1) : PHASE_NAMES_IN_ORDER
256236
);
257237

258238
const mainBarPhases = [];
259239
let previousValue = start;
260240
let previousName = 'startTime';
261241

262242
// In this loop we add the various phases to the array.
263-
availableProperties.forEach((property, i) => {
264-
// We force-coerce the value into a number just to appease Flow. Indeed the
265-
// previous filter ensures that all values are numbers but Flow can't know
266-
// that.
267-
const value = +networkPayload[property];
243+
availablePhases.forEach(({ phase, value }, i) => {
268244
mainBarPhases.push({
269-
name: property,
245+
name: phase,
270246
previousName,
271247
value,
272248
duration: value - previousValue,
273249
style: {
274250
left: ((previousValue - start) / dur) * markerWidth,
275251
width: Math.max(((value - previousValue) / dur) * markerWidth, 1),
276252
// The first phase is always transparent because this represents the wait time.
277-
opacity: i === 0 ? 0 : PHASE_OPACITIES[property],
253+
opacity: i === 0 ? 0 : PHASE_OPACITIES[phase],
278254
},
279255
});
280256
previousValue = value;
281-
previousName = property;
257+
previousName = phase;
282258
});
283259

284260
// The last part isn't generally colored (opacity is 0) unless it's the only
@@ -395,6 +371,10 @@ export class NetworkChartRow extends React.PureComponent<
395371

396372
// Remove `Load 123: ` from markers.name
397373
_cropNameToUrl(name: string): string {
374+
const colonPos = this._findIndexOfLoadid(name);
375+
if (colonPos === null) {
376+
return '';
377+
}
398378
const url = name.slice(this._findIndexOfLoadid(name) + 2);
399379
return url;
400380
}

0 commit comments

Comments
 (0)