Match more Firefox-internal locations (#156)

Looks like Firefox also generates locations with names like
`bound (self-hosted:951:0)`. We check for `self-hosted`, but not for
`self-hosted` with stuff after it following a colon. We should ignore
these too, otherwise we can end up with stuff on our stack that we don't
expect. This was causing Firefox profiles not to load because we
completed building the profile with a non-empty stack.

Attached is a profile that errors without this patch and successfully renders
with this patch.

[copy.json.zip](https://github.com/jlfwong/speedscope/files/2350583/copy.json.zip)
This commit is contained in:
Jonathan Chan 2018-09-04 17:03:55 -07:00 committed by Jamie Wong
parent a09f27d816
commit b6190362b4
5 changed files with 74 additions and 1 deletions

BIN
sample/profiles/Firefox/63/.DS_Store vendored Normal file

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -59,6 +59,70 @@ Object {
}
`;
exports[`importFromFirefox ignore self-hosted 1`] = `
Object {
"frames": Array [
Frame {
"col": undefined,
"file": "http://localhost:8000/simple.js:1",
"key": "alpha (http://localhost:8000/simple.js:1:14)",
"line": 14,
"name": "alpha",
"selfWeight": 0,
"totalWeight": 26.983816999942064,
},
Frame {
"col": undefined,
"file": "http://localhost:8000/simple.js:14",
"key": "delta (http://localhost:8000/simple.js:14:14)",
"line": 14,
"name": "delta",
"selfWeight": 0,
"totalWeight": 11.946324001066387,
},
Frame {
"col": undefined,
"file": "http://localhost:8000/simple.js:20",
"key": "gamma (http://localhost:8000/simple.js:20:14)",
"line": 14,
"name": "gamma",
"selfWeight": 26.983816999942064,
"totalWeight": 26.983816999942064,
},
Frame {
"col": undefined,
"file": "http://localhost:8000/simple.js:8",
"key": "beta (http://localhost:8000/simple.js:8:13)",
"line": 13,
"name": "beta",
"selfWeight": 0,
"totalWeight": 15.037492998875678,
},
],
"name": "simple-firefox.json",
"stacks": Array [
"alpha;delta;gamma 999.57µs",
"alpha;beta;gamma 2.01ms",
"alpha;delta;gamma 1.00ms",
"alpha;beta;gamma 995.68µs",
"alpha;delta;gamma 996.27µs",
"alpha;beta;gamma 4.01ms",
"alpha;delta;gamma 2.02ms",
"alpha;beta;gamma 959.44µs",
"alpha;delta;gamma 2.01ms",
"alpha;beta;gamma 4.01ms",
"alpha;delta;gamma 959.28µs",
"alpha;beta;gamma 2.03ms",
"alpha;delta;gamma 3.96ms",
"alpha;beta;gamma 1.02ms",
],
}
`;
exports[`importFromFirefox ignore self-hosted: indexToView 1`] = `0`;
exports[`importFromFirefox ignore self-hosted: profileGroup.name 1`] = `"simple-firefox.json"`;
exports[`importFromFirefox recursion 1`] = `
Object {
"frames": Array [

View File

@ -7,3 +7,7 @@ test('importFromFirefox', async () => {
test('importFromFirefox recursion', async () => {
await checkProfileSnapshot('./sample/profiles/Firefox/61/recursion.json')
})
test('importFromFirefox ignore self-hosted', async () => {
await checkProfileSnapshot('./sample/profiles/Firefox/63/simple-firefox.json')
})

View File

@ -180,7 +180,11 @@ export function importFromFirefox(firefoxProfile: FirefoxProfile): Profile {
if (!match) return null
if (match[2].startsWith('resource:') || match[2] === 'self-hosted') {
if (
match[2].startsWith('resource:') ||
match[2] === 'self-hosted' ||
match[2].startsWith('self-hosted:')
) {
// Ignore Firefox-internals stuff
return null
}