mirror of https://github.com/golang/go.git
misc/trace: update trace viewer html
The old trace-viewer is broken since Chrome 49:
https://bugs.chromium.org/p/chromium/issues/detail?id=569417
It was fixed in:
506457cbd7
This change updates trace-viewer to the latest version
(now it is called catapult).
This version has a bug in the lean config that we use, though:
https://github.com/catapult-project/catapult/issues/2247
So use full config for now (it works, but leads to larger html).
When the bug is fixed we need to switch back to lean config (issue #15302).
Change-Id: Ifb8d782ced66e3292d81c5604039fe18eaf267c5
Reviewed-on: https://go-review.googlesource.com/22013
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
0ec6d7c0bb
commit
2c9d773f74
|
|
@ -1,12 +1,16 @@
|
||||||
This directory contains helper file for trace viewer (`go tool trace`).
|
This directory contains helper file for trace viewer (`go tool trace`).
|
||||||
|
|
||||||
`trace_viewer_lean.html` was generated by following
|
`trace_viewer_lean.html` was generated by following
|
||||||
[instructions](https://github.com/google/trace-viewer/wiki/Embedding)
|
[instructions](https://github.com/catapult-project/catapult/blob/master/tracing/docs/embedding-trace-viewer.md)
|
||||||
on revision `280626ef607decf36291e290d5f0322b173e8a7f` using:
|
on revision `623a005a3ffa9de13c4b92bc72290e7bcd1ca591`
|
||||||
|
of [catapult](https://github.com/catapult-project/catapult) using:
|
||||||
```
|
```
|
||||||
trace-viewer$ ./vulcanize_trace_viewer --config=lean
|
catapult$ ./tracing/bin/vulcanize_trace_viewer --config=full
|
||||||
trace-viewer$ cp bin/trace_viewer_lean.html $GOROOT/misc/trace/
|
catapult$ cp tracing/bin/trace_viewer_full.html $GOROOT/misc/trace/trace_viewer_lean.html
|
||||||
```
|
```
|
||||||
|
We are supposed to use --config=lean (produces smaller html),
|
||||||
|
but it is broken at the moment:
|
||||||
|
https://github.com/catapult-project/catapult/issues/2247
|
||||||
|
|
||||||
The license for trace-viewer is as follows:
|
The license for trace-viewer is as follows:
|
||||||
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -44,19 +44,88 @@ func httpTrace(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://github.com/catapult-project/catapult/blob/master/tracing/docs/embedding-trace-viewer.md
|
||||||
|
// This is almost verbatim copy of:
|
||||||
|
// https://github.com/catapult-project/catapult/blob/master/tracing/bin/index.html
|
||||||
|
// on revision 623a005a3ffa9de13c4b92bc72290e7bcd1ca591.
|
||||||
var templTrace = `
|
var templTrace = `
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<link href="/trace_viewer_html" rel="import">
|
<link href="/trace_viewer_html" rel="import">
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener("DOMContentLoaded", function(event) {
|
(function() {
|
||||||
var viewer = new tr.TraceViewer('/jsontrace{{PARAMS}}');
|
var viewer;
|
||||||
|
var url;
|
||||||
|
var model;
|
||||||
|
|
||||||
|
function load() {
|
||||||
|
var req = new XMLHttpRequest();
|
||||||
|
var is_binary = /[.]gz$/.test(url) || /[.]zip$/.test(url);
|
||||||
|
req.overrideMimeType('text/plain; charset=x-user-defined');
|
||||||
|
req.open('GET', url, true);
|
||||||
|
if (is_binary)
|
||||||
|
req.responseType = 'arraybuffer';
|
||||||
|
|
||||||
|
req.onreadystatechange = function(event) {
|
||||||
|
if (req.readyState !== 4)
|
||||||
|
return;
|
||||||
|
|
||||||
|
window.setTimeout(function() {
|
||||||
|
if (req.status === 200)
|
||||||
|
onResult(is_binary ? req.response : req.responseText);
|
||||||
|
else
|
||||||
|
onResultFail(req.status);
|
||||||
|
}, 0);
|
||||||
|
};
|
||||||
|
req.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onResultFail(err) {
|
||||||
|
var overlay = new tr.ui.b.Overlay();
|
||||||
|
overlay.textContent = err + ': ' + url + ' could not be loaded';
|
||||||
|
overlay.title = 'Failed to fetch data';
|
||||||
|
overlay.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onResult(result) {
|
||||||
|
model = new tr.Model();
|
||||||
|
var i = new tr.importer.Import(model);
|
||||||
|
var p = i.importTracesWithProgressDialog([result]);
|
||||||
|
p.then(onModelLoaded, onImportFail);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onModelLoaded() {
|
||||||
|
viewer.model = model;
|
||||||
|
viewer.viewTitle = "trace";
|
||||||
|
}
|
||||||
|
|
||||||
|
function onImportFail() {
|
||||||
|
var overlay = new tr.ui.b.Overlay();
|
||||||
|
overlay.textContent = tr.b.normalizeException(err).message;
|
||||||
|
overlay.title = 'Import error';
|
||||||
|
overlay.visible = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
var container = document.createElement('track-view-container');
|
||||||
|
container.id = 'track_view_container';
|
||||||
|
|
||||||
|
viewer = document.createElement('tr-ui-timeline-view');
|
||||||
|
viewer.track_view_container = container;
|
||||||
|
viewer.appendChild(container);
|
||||||
|
|
||||||
|
viewer.id = 'trace-viewer';
|
||||||
|
viewer.globalMode = true;
|
||||||
document.body.appendChild(viewer);
|
document.body.appendChild(viewer);
|
||||||
|
|
||||||
|
url = '/jsontrace{{PARAMS}}';
|
||||||
|
load();
|
||||||
});
|
});
|
||||||
</script>
|
}());
|
||||||
</head>
|
</script>
|
||||||
<body>
|
</head>
|
||||||
</body>
|
<body>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue