From 16e32dc08e37948b931b6c9b132398f1c7493daf Mon Sep 17 00:00:00 2001 From: Jamie Wong Date: Fri, 2 Oct 2020 14:56:22 -0700 Subject: [PATCH] Normalize line & column numbers to be 1-based in Chrome & Firefox imports (#318) This also fixes a dumb bug in the Firefox import that just completely failed to import column numbers. --- src/import/__snapshots__/chrome.test.ts.snap | 606 +++++++++--------- src/import/__snapshots__/firefox.test.ts.snap | 22 +- src/import/chrome.ts | 13 +- src/import/firefox.ts | 6 +- src/views/flamechart-detail-view.tsx | 4 +- 5 files changed, 332 insertions(+), 319 deletions(-) diff --git a/src/import/__snapshots__/chrome.test.ts.snap b/src/import/__snapshots__/chrome.test.ts.snap index 1dd0be8..ff3c100 100644 --- a/src/import/__snapshots__/chrome.test.ts.snap +++ b/src/import/__snapshots__/chrome.test.ts.snap @@ -4,46 +4,46 @@ exports[`importFromChromeCPUProfile 1`] = ` Object { "frames": Array [ Frame { - "col": 0, + "col": 1, "file": "", - "key": "(anonymous)::0:0", - "line": 0, + "key": "(anonymous)::1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 1060, "totalWeight": 34345, }, Frame { - "col": 10, + "col": 11, "file": "", - "key": "a::0:10", - "line": 0, + "key": "a::1:11", + "line": 1, "name": "a", "selfWeight": 0, "totalWeight": 33285, }, Frame { - "col": 10, + "col": 11, "file": "", - "key": "b::5:10", - "line": 5, + "key": "b::6:11", + "line": 6, "name": "b", "selfWeight": 0, "totalWeight": 17002, }, Frame { - "col": 10, + "col": 11, "file": "", - "key": "d::13:10", - "line": 13, + "key": "d::14:11", + "line": 14, "name": "d", "selfWeight": 33285, "totalWeight": 33285, }, Frame { - "col": 10, + "col": 11, "file": "", - "key": "c::9:10", - "line": 9, + "key": "c::10:11", + "line": 10, "name": "c", "selfWeight": 0, "totalWeight": 16283, @@ -67,37 +67,37 @@ exports[`importFromChromeTimeline 1`] = ` Object { "frames": Array [ Frame { - "col": -1, + "col": 0, "file": "", - "key": "(program)::-1:-1", - "line": -1, + "key": "(program)::0:0", + "line": 0, "name": "(program)", "selfWeight": 2299, "totalWeight": 2299, }, Frame { - "col": 10, + "col": 11, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "a:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:0:10", - "line": 0, + "key": "a:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:1:11", + "line": 1, "name": "a", "selfWeight": 0, "totalWeight": 33186, }, Frame { - "col": 10, + "col": 11, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "c:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:13:10", - "line": 13, + "key": "c:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:14:11", + "line": 14, "name": "c", "selfWeight": 16275, "totalWeight": 16275, }, Frame { - "col": 10, + "col": 11, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "b:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:7:10", - "line": 7, + "key": "b:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:8:11", + "line": 8, "name": "b", "selfWeight": 16911, "totalWeight": 16911, @@ -266,28 +266,28 @@ exports[`importFromChromeTimeline Chrome 69 1`] = ` Object { "frames": Array [ Frame { - "col": 0, + "col": 1, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:0:0", - "line": 0, + "key": "(anonymous):extensions::SafeBuiltins:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 3188, }, Frame { - "col": 9, + "col": 10, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:0:9", - "line": 0, + "key": "(anonymous):extensions::SafeBuiltins:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 3188, }, Frame { - "col": 20, + "col": 21, "file": "extensions::SafeBuiltins", - "key": "saveBuiltin:extensions::SafeBuiltins:24:20", - "line": 24, + "key": "saveBuiltin:extensions::SafeBuiltins:25:21", + "line": 25, "name": "saveBuiltin", "selfWeight": 302, "totalWeight": 3188, @@ -302,46 +302,46 @@ Object { "totalWeight": 6862, }, Frame { - "col": 0, + "col": 1, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "(anonymous):file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:0:0", - "line": 0, + "key": "(anonymous):file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 136, "totalWeight": 37217, }, Frame { - "col": 14, + "col": 15, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "alpha:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:0:14", - "line": 0, + "key": "alpha:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:1:15", + "line": 1, "name": "alpha", "selfWeight": 873, "totalWeight": 37081, }, Frame { - "col": 13, + "col": 14, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "beta:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:7:13", - "line": 7, + "key": "beta:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:8:14", + "line": 8, "name": "beta", "selfWeight": 7552, "totalWeight": 17562, }, Frame { - "col": 14, + "col": 15, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "gamma:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:19:14", - "line": 19, + "key": "gamma:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:20:15", + "line": 20, "name": "gamma", "selfWeight": 20018, "totalWeight": 20018, }, Frame { - "col": 14, + "col": 15, "file": "file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js", - "key": "delta:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:13:14", - "line": 13, + "key": "delta:file:///Users/jlfwong/code/speedscope/sample/programs/javascript/simple.js:14:15", + "line": 14, "name": "delta", "selfWeight": 7179, "totalWeight": 18646, @@ -519,172 +519,172 @@ exports[`importFromChromeTimeline Workers Chrome 66 1`] = ` Object { "frames": Array [ Frame { - "col": -1, + "col": 0, "file": "", - "key": "(program)::-1:-1", - "line": -1, + "key": "(program)::0:0", + "line": 0, "name": "(program)", "selfWeight": 106601, "totalWeight": 108131, }, Frame { - "col": 8, + "col": 9, "file": "", - "key": "(anonymous)::247:8", - "line": 247, + "key": "(anonymous)::248:9", + "line": 248, "name": "(anonymous)", "selfWeight": 551, "totalWeight": 2766, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "addEventListener::-1:-1", - "line": -1, + "key": "addEventListener::0:0", + "line": 0, "name": "addEventListener", "selfWeight": 178, "totalWeight": 2215, }, Frame { - "col": 17, + "col": 18, "file": "", - "key": "onLoaded::866:17", - "line": 866, + "key": "onLoaded::867:18", + "line": 867, "name": "onLoaded", "selfWeight": 372, "totalWeight": 5158, }, Frame { - "col": 0, + "col": 1, "file": "", - "key": "(anonymous)::0:0", - "line": 0, + "key": "(anonymous)::1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 25649, }, Frame { - "col": 17, + "col": 18, "file": "", - "key": "dispatch::845:17", - "line": 845, + "key": "dispatch::846:18", + "line": 846, "name": "dispatch", "selfWeight": 1103, "totalWeight": 25649, }, Frame { - "col": 20, + "col": 21, "file": "", - "key": "setPlatform::839:20", - "line": 839, + "key": "setPlatform::840:21", + "line": 840, "name": "setPlatform", "selfWeight": 0, "totalWeight": 902, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "add::-1:-1", - "line": -1, + "key": "add::0:0", + "line": 0, "name": "add", "selfWeight": 521, "totalWeight": 902, }, Frame { - "col": 14, + "col": 15, "file": "", - "key": "reset::433:14", - "line": 433, + "key": "reset::434:15", + "line": 434, "name": "reset", "selfWeight": 911, "totalWeight": 2438, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "getContext::-1:-1", - "line": -1, + "key": "getContext::0:0", + "line": 0, "name": "getContext", "selfWeight": 598, "totalWeight": 598, }, Frame { - "col": 20, + "col": 21, "file": "", - "key": "resetCanvas::423:20", - "line": 423, + "key": "resetCanvas::424:21", + "line": 424, "name": "resetCanvas", "selfWeight": 370, "totalWeight": 553, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "scale::-1:-1", - "line": -1, + "key": "scale::0:0", + "line": 0, "name": "scale", "selfWeight": 183, "totalWeight": 183, }, Frame { - "col": 8, + "col": 9, "file": "http://172.30.3.176:7777/worker.html", - "key": "(anonymous):http://172.30.3.176:7777/worker.html:0:8", - "line": 0, + "key": "(anonymous):http://172.30.3.176:7777/worker.html:1:9", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 2524, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "Worker::-1:-1", - "line": -1, + "key": "Worker::0:0", + "line": 0, "name": "Worker", "selfWeight": 806, "totalWeight": 2524, }, Frame { - "col": 29, + "col": 30, "file": "http://172.30.3.176:7777/worker.html", - "key": "worker.onmessage:http://172.30.3.176:7777/worker.html:19:29", - "line": 19, + "key": "worker.onmessage:http://172.30.3.176:7777/worker.html:20:30", + "line": 20, "name": "worker.onmessage", "selfWeight": 1221, "totalWeight": 60859, }, Frame { - "col": 16, + "col": 17, "file": "http://172.30.3.176:7777/worker.html", - "key": "apple:http://172.30.3.176:7777/worker.html:9:16", - "line": 9, + "key": "apple:http://172.30.3.176:7777/worker.html:10:17", + "line": 10, "name": "apple", "selfWeight": 5474, "totalWeight": 58863, }, Frame { - "col": 17, + "col": 18, "file": "http://172.30.3.176:7777/worker.html", - "key": "banana:http://172.30.3.176:7777/worker.html:1:17", - "line": 1, + "key": "banana:http://172.30.3.176:7777/worker.html:2:18", + "line": 2, "name": "banana", "selfWeight": 50635, "totalWeight": 53816, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "postMessage::-1:-1", - "line": -1, + "key": "postMessage::0:0", + "line": 0, "name": "postMessage", "selfWeight": 348, "totalWeight": 348, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "(garbage collector)::-1:-1", - "line": -1, + "key": "(garbage collector)::0:0", + "line": 0, "name": "(garbage collector)", "selfWeight": 1530, "totalWeight": 1530, @@ -826,46 +826,46 @@ exports[`importFromChromeTimeline Workers Chrome 66 2`] = ` Object { "frames": Array [ Frame { - "col": -1, + "col": 0, "file": "", - "key": "(program)::-1:-1", - "line": -1, + "key": "(program)::0:0", + "line": 0, "name": "(program)", "selfWeight": 819120, "totalWeight": 819120, }, Frame { - "col": 20, + "col": 21, "file": "http://172.30.3.176:7777/worker.js", - "key": "onmessage:http://172.30.3.176:7777/worker.js:14:20", - "line": 14, + "key": "onmessage:http://172.30.3.176:7777/worker.js:15:21", + "line": 15, "name": "onmessage", "selfWeight": 639, "totalWeight": 857719, }, Frame { - "col": 14, + "col": 15, "file": "http://172.30.3.176:7777/worker.js", - "key": "alpha:http://172.30.3.176:7777/worker.js:8:14", - "line": 8, + "key": "alpha:http://172.30.3.176:7777/worker.js:9:15", + "line": 9, "name": "alpha", "selfWeight": 19976, "totalWeight": 835149, }, Frame { - "col": 14, + "col": 15, "file": "http://172.30.3.176:7777/worker.js", - "key": "gamma:http://172.30.3.176:7777/worker.js:0:14", - "line": 0, + "key": "gamma:http://172.30.3.176:7777/worker.js:1:15", + "line": 1, "name": "gamma", "selfWeight": 22197, "totalWeight": 30000, }, Frame { - "col": -1, + "col": 0, "file": "", - "key": "postMessage::-1:-1", - "line": -1, + "key": "postMessage::0:0", + "line": 0, "name": "postMessage", "selfWeight": 1278, "totalWeight": 21931, @@ -921,46 +921,46 @@ exports[`importFromChromeTimeline Workers Chrome 70 1`] = ` Object { "frames": Array [ Frame { - "col": 0, + "col": 1, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:0:0", - "line": 0, + "key": "(anonymous):extensions::SafeBuiltins:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 37463, }, Frame { - "col": 9, + "col": 10, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:0:9", - "line": 0, + "key": "(anonymous):extensions::SafeBuiltins:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 37463, }, Frame { - "col": 20, + "col": 21, "file": "extensions::SafeBuiltins", - "key": "saveBuiltin:extensions::SafeBuiltins:24:20", - "line": 24, + "key": "saveBuiltin:extensions::SafeBuiltins:25:21", + "line": 25, "name": "saveBuiltin", "selfWeight": 233, "totalWeight": 9858, }, Frame { - "col": 21, + "col": 22, "file": "extensions::SafeBuiltins", - "key": "makeCallable:extensions::SafeBuiltins:6:21", - "line": 6, + "key": "makeCallable:extensions::SafeBuiltins:7:22", + "line": 7, "name": "makeCallable", "selfWeight": 122, "totalWeight": 7007, }, Frame { - "col": 32, + "col": 33, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:7:32", - "line": 7, + "key": "(anonymous):extensions::SafeBuiltins:8:33", + "line": 8, "name": "(anonymous)", "selfWeight": 234, "totalWeight": 234, @@ -984,19 +984,19 @@ Object { "totalWeight": 3380, }, Frame { - "col": 0, + "col": 1, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:0:0", - "line": 0, + "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 1550, "totalWeight": 15220, }, Frame { - "col": 466, + "col": 467, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "La:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:34:466", - "line": 34, + "key": "La:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:35:467", + "line": 35, "name": "La", "selfWeight": 407, "totalWeight": 11272, @@ -1011,10 +1011,10 @@ Object { "totalWeight": 15564, }, Frame { - "col": 9, + "col": 10, "file": "extensions::runtime", - "key": "(anonymous):extensions::runtime:0:9", - "line": 0, + "key": "(anonymous):extensions::runtime:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 2319, "totalWeight": 15277, @@ -1029,64 +1029,64 @@ Object { "totalWeight": 6636, }, Frame { - "col": 9, + "col": 10, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:0:9", - "line": 0, + "key": "(anonymous):extensions::binding:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 791, "totalWeight": 4994, }, Frame { - "col": 9, + "col": 10, "file": "extensions::event_bindings", - "key": "(anonymous):extensions::event_bindings:0:9", - "line": 0, + "key": "(anonymous):extensions::event_bindings:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 822, "totalWeight": 4068, }, Frame { - "col": 9, + "col": 10, "file": "extensions::sendRequest", - "key": "(anonymous):extensions::sendRequest:0:9", - "line": 0, + "key": "(anonymous):extensions::sendRequest:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 761, "totalWeight": 2844, }, Frame { - "col": 9, + "col": 10, "file": "extensions::schemaUtils", - "key": "(anonymous):extensions::schemaUtils:0:9", - "line": 0, + "key": "(anonymous):extensions::schemaUtils:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 847, "totalWeight": 1814, }, Frame { - "col": 9, + "col": 10, "file": "extensions::json_schema", - "key": "(anonymous):extensions::json_schema:0:9", - "line": 0, + "key": "(anonymous):extensions::json_schema:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 834, "totalWeight": 834, }, Frame { - "col": 15, + "col": 16, "file": "extensions::utils", - "key": "expose:extensions::utils:97:15", - "line": 97, + "key": "expose:extensions::utils:98:16", + "line": 98, "name": "expose", "selfWeight": 147, "totalWeight": 293, }, Frame { - "col": 35, + "col": 36, "file": "extensions::SafeBuiltins", - "key": "target.(anonymous function):extensions::SafeBuiltins:9:35", - "line": 9, + "key": "target.(anonymous function):extensions::SafeBuiltins:10:36", + "line": 10, "name": "target.(anonymous function)", "selfWeight": 727, "totalWeight": 7136, @@ -1101,226 +1101,226 @@ Object { "totalWeight": 6547, }, Frame { - "col": 9, + "col": 10, "file": "extensions::messaging", - "key": "(anonymous):extensions::messaging:0:9", - "line": 0, + "key": "(anonymous):extensions::messaging:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 151, "totalWeight": 428, }, Frame { - "col": 20, + "col": 21, "file": "extensions::binding", - "key": "generate:extensions::binding:198:20", - "line": 198, + "key": "generate:extensions::binding:199:21", + "line": 199, "name": "generate", "selfWeight": 149, "totalWeight": 7002, }, Frame { - "col": 36, + "col": 37, "file": "extensions::binding", - "key": "shouldCheckUnprivileged:extensions::binding:208:36", - "line": 208, + "key": "shouldCheckUnprivileged:extensions::binding:209:37", + "line": 209, "name": "shouldCheckUnprivileged", "selfWeight": 0, "totalWeight": 146, }, Frame { - "col": 43, + "col": 44, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:252:43", - "line": 252, + "key": "(anonymous):extensions::binding:253:44", + "line": 253, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 3651, }, Frame { - "col": 49, + "col": 50, "file": "extensions::json_schema", - "key": "JSONSchemaValidator.addTypes:extensions::json_schema:173:49", - "line": 173, + "key": "JSONSchemaValidator.addTypes:extensions::json_schema:174:50", + "line": 174, "name": "JSONSchemaValidator.addTypes", "selfWeight": 149, "totalWeight": 149, }, Frame { - "col": 45, + "col": 46, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:270:45", - "line": 270, + "key": "(anonymous):extensions::binding:271:46", + "line": 271, "name": "(anonymous)", "selfWeight": 546, "totalWeight": 3349, }, Frame { - "col": 47, + "col": 48, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:322:47", - "line": 322, + "key": "(anonymous):extensions::binding:323:48", + "line": 323, "name": "(anonymous)", "selfWeight": 159, "totalWeight": 586, }, Frame { - "col": 44, + "col": 45, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:396:44", - "line": 396, + "key": "(anonymous):extensions::binding:397:45", + "line": 397, "name": "(anonymous)", "selfWeight": 142, "totalWeight": 802, }, Frame { - "col": 16, + "col": 17, "file": "extensions::event_bindings", - "key": "Event:extensions::event_bindings:512:16", - "line": 512, + "key": "Event:extensions::event_bindings:513:17", + "line": 513, "name": "Event", "selfWeight": 139, "totalWeight": 527, }, Frame { - "col": 51, + "col": 52, "file": "extensions::utils", - "key": "privates.constructPrivate:extensions::utils:101:51", - "line": 101, + "key": "privates.constructPrivate:extensions::utils:102:52", + "line": 102, "name": "privates.constructPrivate", "selfWeight": 0, "totalWeight": 388, }, Frame { - "col": 20, + "col": 21, "file": "extensions::event_bindings", - "key": "EventImpl:extensions::event_bindings:212:20", - "line": 212, + "key": "EventImpl:extensions::event_bindings:213:21", + "line": 213, "name": "EventImpl", "selfWeight": 251, "totalWeight": 251, }, Frame { - "col": 26, + "col": 27, "file": "extensions::binding", - "key": "addProperties:extensions::binding:424:26", - "line": 424, + "key": "addProperties:extensions::binding:425:27", + "line": 425, "name": "addProperties", "selfWeight": 149, "totalWeight": 710, }, Frame { - "col": 16, + "col": 17, "file": "extensions::utils", - "key": "forEach:extensions::utils:26:16", - "line": 26, + "key": "forEach:extensions::utils:27:17", + "line": 27, "name": "forEach", "selfWeight": 0, "totalWeight": 561, }, Frame { - "col": 21, + "col": 22, "file": "extensions::binding", - "key": "runHooks_:extensions::binding:179:21", - "line": 179, + "key": "runHooks_:extensions::binding:180:22", + "line": 180, "name": "runHooks_", "selfWeight": 0, "totalWeight": 273, }, Frame { - "col": 46, + "col": 47, "file": "extensions::binding", - "key": "(anonymous):extensions::binding:180:46", - "line": 180, + "key": "(anonymous):extensions::binding:181:47", + "line": 181, "name": "(anonymous)", "selfWeight": 141, "totalWeight": 273, }, Frame { - "col": 35, + "col": 36, "file": "extensions::runtime", - "key": "(anonymous):extensions::runtime:16:35", - "line": 16, + "key": "(anonymous):extensions::runtime:17:36", + "line": 17, "name": "(anonymous)", "selfWeight": 132, "totalWeight": 132, }, Frame { - "col": 260, + "col": 261, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "l:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:37:260", - "line": 37, + "key": "l:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:38:261", + "line": 38, "name": "l", "selfWeight": 127, "totalWeight": 127, }, Frame { - "col": 43, + "col": 44, "file": "extensions::utils", - "key": "publicClassPrototype.(anonymous function):extensions::utils:135:43", - "line": 135, + "key": "publicClassPrototype.(anonymous function):extensions::utils:136:44", + "line": 136, "name": "publicClassPrototype.(anonymous function)", "selfWeight": 0, "totalWeight": 276, }, Frame { - "col": 44, + "col": 45, "file": "extensions::event_bindings", - "key": "EventImpl.addListener:extensions::event_bindings:272:44", - "line": 272, + "key": "EventImpl.addListener:extensions::event_bindings:273:45", + "line": 273, "name": "EventImpl.addListener", "selfWeight": 135, "totalWeight": 135, }, Frame { - "col": 161, + "col": 162, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "bb:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:57:161", - "line": 57, + "key": "bb:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:58:162", + "line": 58, "name": "bb", "selfWeight": 146, "totalWeight": 146, }, Frame { - "col": 9, + "col": 10, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:64:9", - "line": 64, + "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:65:10", + "line": 65, "name": "(anonymous)", "selfWeight": 141, "totalWeight": 1071, }, Frame { - "col": 46, + "col": 47, "file": "extensions::SafeBuiltins", - "key": "(anonymous):extensions::SafeBuiltins:65:46", - "line": 65, + "key": "(anonymous):extensions::SafeBuiltins:66:47", + "line": 66, "name": "(anonymous)", "selfWeight": 116, "totalWeight": 27605, }, Frame { - "col": 0, + "col": 1, "file": "chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js", - "key": "(anonymous):chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:0:0", - "line": 0, + "key": "(anonymous):chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 542, "totalWeight": 6115, }, Frame { - "col": 25, + "col": 26, "file": "chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js", - "key": "insertTextScript:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:30:25", - "line": 30, + "key": "insertTextScript:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:31:26", + "line": 31, "name": "insertTextScript", "selfWeight": 392, "totalWeight": 874, }, Frame { - "col": 25, + "col": 26, "file": "chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js", - "key": "insertHeaderNode:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:57:25", - "line": 57, + "key": "insertHeaderNode:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:58:26", + "line": 58, "name": "insertHeaderNode", "selfWeight": 189, "totalWeight": 482, @@ -1335,37 +1335,37 @@ Object { "totalWeight": 293, }, Frame { - "col": 0, + "col": 1, "file": undefined, - "key": "(anonymous):undefined:0:0", - "line": 0, + "key": "(anonymous):undefined:1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 148, }, Frame { - "col": 13, + "col": 14, "file": undefined, - "key": "(anonymous):undefined:6:13", - "line": 6, + "key": "(anonymous):undefined:7:14", + "line": 7, "name": "(anonymous)", "selfWeight": 148, "totalWeight": 148, }, Frame { - "col": 25, + "col": 26, "file": "chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js", - "key": "listenForMessage:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:24:25", - "line": 24, + "key": "listenForMessage:chrome-extension://denbgaamihkadbghdceggmchnflmhpmk/contentScript.js:25:26", + "line": 25, "name": "listenForMessage", "selfWeight": 0, "totalWeight": 4699, }, Frame { - "col": 9, + "col": 10, "file": "extensions::uncaught_exception_handler", - "key": "(anonymous):extensions::uncaught_exception_handler:0:9", - "line": 0, + "key": "(anonymous):extensions::uncaught_exception_handler:1:10", + "line": 1, "name": "(anonymous)", "selfWeight": 121, "totalWeight": 121, @@ -1380,10 +1380,10 @@ Object { "totalWeight": 135, }, Frame { - "col": 8, + "col": 9, "file": "http://127.0.0.1:8081/worker.html", - "key": "(anonymous):http://127.0.0.1:8081/worker.html:0:8", - "line": 0, + "key": "(anonymous):http://127.0.0.1:8081/worker.html:1:9", + "line": 1, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 939, @@ -1398,28 +1398,28 @@ Object { "totalWeight": 939, }, Frame { - "col": 11, + "col": 12, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "cb:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:49:11", - "line": 49, + "key": "cb:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:50:12", + "line": 50, "name": "cb", "selfWeight": 0, "totalWeight": 359, }, Frame { - "col": 314, + "col": 315, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "$a:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:46:314", - "line": 46, + "key": "$a:chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:47:315", + "line": 47, "name": "$a", "selfWeight": 278, "totalWeight": 359, }, Frame { - "col": 51, + "col": 52, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:50:51", - "line": 50, + "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:51:52", + "line": 51, "name": "(anonymous)", "selfWeight": 0, "totalWeight": 683, @@ -1434,37 +1434,37 @@ Object { "totalWeight": 704, }, Frame { - "col": 144, + "col": 145, "file": "chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js", - "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:50:144", - "line": 50, + "key": "(anonymous):chrome-extension://aomjjhallfgjeglblehebfpbcfeobpgk/injected.min.js:51:145", + "line": 51, "name": "(anonymous)", "selfWeight": 117, "totalWeight": 678, }, Frame { - "col": 29, + "col": 30, "file": "http://127.0.0.1:8081/worker.html", - "key": "worker.onmessage:http://127.0.0.1:8081/worker.html:19:29", - "line": 19, + "key": "worker.onmessage:http://127.0.0.1:8081/worker.html:20:30", + "line": 20, "name": "worker.onmessage", "selfWeight": 0, "totalWeight": 21103, }, Frame { - "col": 16, + "col": 17, "file": "http://127.0.0.1:8081/worker.html", - "key": "apple:http://127.0.0.1:8081/worker.html:9:16", - "line": 9, + "key": "apple:http://127.0.0.1:8081/worker.html:10:17", + "line": 10, "name": "apple", "selfWeight": 660, "totalWeight": 20852, }, Frame { - "col": 17, + "col": 18, "file": "http://127.0.0.1:8081/worker.html", - "key": "banana:http://127.0.0.1:8081/worker.html:1:17", - "line": 1, + "key": "banana:http://127.0.0.1:8081/worker.html:2:18", + "line": 2, "name": "banana", "selfWeight": 18755, "totalWeight": 20192, @@ -1667,28 +1667,28 @@ exports[`importFromChromeTimeline Workers Chrome 70 2`] = ` Object { "frames": Array [ Frame { - "col": 20, + "col": 21, "file": "http://127.0.0.1:8081/worker.js", - "key": "onmessage:http://127.0.0.1:8081/worker.js:14:20", - "line": 14, + "key": "onmessage:http://127.0.0.1:8081/worker.js:15:21", + "line": 15, "name": "onmessage", "selfWeight": 402, "totalWeight": 187278, }, Frame { - "col": 14, + "col": 15, "file": "http://127.0.0.1:8081/worker.js", - "key": "alpha:http://127.0.0.1:8081/worker.js:8:14", - "line": 8, + "key": "alpha:http://127.0.0.1:8081/worker.js:9:15", + "line": 9, "name": "alpha", "selfWeight": 7945, "totalWeight": 177837, }, Frame { - "col": 14, + "col": 15, "file": "http://127.0.0.1:8081/worker.js", - "key": "gamma:http://127.0.0.1:8081/worker.js:0:14", - "line": 0, + "key": "gamma:http://127.0.0.1:8081/worker.js:1:15", + "line": 1, "name": "gamma", "selfWeight": 13631, "totalWeight": 21888, @@ -1764,46 +1764,46 @@ exports[`importFromV8Profiler Node 10 1`] = ` Object { "frames": Array [ Frame { - "col": 0, + "col": 1, "file": "", - "key": "(anonymous)::0:0", - "line": 0, + "key": "(anonymous)::1:1", + "line": 1, "name": "(anonymous)", "selfWeight": 11575, "totalWeight": 44777, }, Frame { - "col": 0, + "col": 1, "file": "", - "key": "a::0:0", - "line": 0, + "key": "a::1:1", + "line": 1, "name": "a", "selfWeight": 0, "totalWeight": 33202, }, Frame { - "col": 0, + "col": 1, "file": "", - "key": "b::5:0", - "line": 5, + "key": "b::6:1", + "line": 6, "name": "b", "selfWeight": 0, "totalWeight": 16788, }, Frame { - "col": 0, + "col": 1, "file": "", - "key": "d::13:0", - "line": 13, + "key": "d::14:1", + "line": 14, "name": "d", "selfWeight": 33202, "totalWeight": 33202, }, Frame { - "col": 0, + "col": 1, "file": "", - "key": "c::9:0", - "line": 9, + "key": "c::10:1", + "line": 10, "name": "c", "selfWeight": 0, "totalWeight": 16414, diff --git a/src/import/__snapshots__/firefox.test.ts.snap b/src/import/__snapshots__/firefox.test.ts.snap index 1f70e22..0784e3d 100644 --- a/src/import/__snapshots__/firefox.test.ts.snap +++ b/src/import/__snapshots__/firefox.test.ts.snap @@ -64,17 +64,17 @@ exports[`importFromFirefox ignore self-hosted 1`] = ` Object { "frames": Array [ Frame { - "col": undefined, - "file": "http://localhost:8000/simple.js:1", + "col": 15, + "file": "http://localhost:8000/simple.js", "key": "alpha (http://localhost:8000/simple.js:1:14)", - "line": 14, + "line": 1, "name": "alpha", "selfWeight": 0, "totalWeight": 26.983816999942064, }, Frame { - "col": undefined, - "file": "http://localhost:8000/simple.js:14", + "col": 15, + "file": "http://localhost:8000/simple.js", "key": "delta (http://localhost:8000/simple.js:14:14)", "line": 14, "name": "delta", @@ -82,19 +82,19 @@ Object { "totalWeight": 11.946324001066387, }, Frame { - "col": undefined, - "file": "http://localhost:8000/simple.js:20", + "col": 15, + "file": "http://localhost:8000/simple.js", "key": "gamma (http://localhost:8000/simple.js:20:14)", - "line": 14, + "line": 20, "name": "gamma", "selfWeight": 26.983816999942064, "totalWeight": 26.983816999942064, }, Frame { - "col": undefined, - "file": "http://localhost:8000/simple.js:8", + "col": 14, + "file": "http://localhost:8000/simple.js", "key": "beta (http://localhost:8000/simple.js:8:13)", - "line": 13, + "line": 8, "name": "beta", "selfWeight": 0, "totalWeight": 15.037492998875678, diff --git a/src/import/chrome.ts b/src/import/chrome.ts index 04a86f8..2368d52 100644 --- a/src/import/chrome.ts +++ b/src/import/chrome.ts @@ -170,8 +170,17 @@ function frameInfoForCallFrame(callFrame: CPUProfileCallFrame) { return getOrInsert(callFrameToFrameInfo, callFrame, callFrame => { const name = callFrame.functionName || '(anonymous)' const file = callFrame.url - const line = callFrame.lineNumber - const col = callFrame.columnNumber + + // In Chrome profiles, line numbers & column numbers are both 0-indexed. + // + // We're going to normalize these to be 1-based to avoid needing to normalize + // these at the presentation layer. + let line = callFrame.lineNumber + if (line != null) line++ + + let col = callFrame.columnNumber + if (col != null) col++ + return { key: `${name}:${file}:${line}:${col}`, name, diff --git a/src/import/firefox.ts b/src/import/firefox.ts index 1a12d75..6a42bf9 100644 --- a/src/import/firefox.ts +++ b/src/import/firefox.ts @@ -176,7 +176,7 @@ export function importFromFirefox(firefoxProfile: FirefoxProfile): Profile { const frameData = thread.frameTable.data[f] const location = thread.stringTable[frameData[0]] - const match = /(.*)\s+\((.*?):?(\d+)?\)$/.exec(location) + const match = /(.*)\s+\((.*?)(?::(\d+))?(?::(\d+))?\)$/.exec(location) if (!match) return null @@ -193,7 +193,11 @@ export function importFromFirefox(firefoxProfile: FirefoxProfile): Profile { key: location, name: match[1]!, file: match[2]!, + + // In Firefox profiles, line numbers are 1-based, but columns are + // 0-based. Let's normalize both to be 1-based. line: match[3] ? parseInt(match[3]) : undefined, + col: match[4] ? parseInt(match[4]) + 1 : undefined, })) }) .filter(f => f != null) as FrameInfo[] diff --git a/src/views/flamechart-detail-view.tsx b/src/views/flamechart-detail-view.tsx index d222e70..19a58ff 100644 --- a/src/views/flamechart-detail-view.tsx +++ b/src/views/flamechart-detail-view.tsx @@ -68,9 +68,9 @@ class StackTraceView extends Component { if (frame.file) { let pos = frame.file - if (frame.line) { + if (frame.line != null) { pos += `:${frame.line}` - if (frame.col) { + if (frame.col != null) { pos += `:${frame.col}` } }