Commit 2c9d773f authored by Dmitry Vyukov's avatar Dmitry Vyukov

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:
https://github.com/catapult-project/catapult/commit/506457cbd726324f327b80ae11f46c1dfeb8710d

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/22013Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 0ec6d7c0
This directory contains helper file for trace viewer (`go tool trace`).
`trace_viewer_lean.html` was generated by following
[instructions](https://github.com/google/trace-viewer/wiki/Embedding)
on revision `280626ef607decf36291e290d5f0322b173e8a7f` using:
[instructions](https://github.com/catapult-project/catapult/blob/master/tracing/docs/embedding-trace-viewer.md)
on revision `623a005a3ffa9de13c4b92bc72290e7bcd1ca591`
of [catapult](https://github.com/catapult-project/catapult) using:
```
trace-viewer$ ./vulcanize_trace_viewer --config=lean
trace-viewer$ cp bin/trace_viewer_lean.html $GOROOT/misc/trace/
catapult$ ./tracing/bin/vulcanize_trace_viewer --config=full
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:
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
......
This diff is collapsed.
......@@ -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 = `
<html>
<head>
<link href="/trace_viewer_html" rel="import">
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var viewer = new tr.TraceViewer('/jsontrace{{PARAMS}}');
<head>
<link href="/trace_viewer_html" rel="import">
<script>
(function() {
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);
url = '/jsontrace{{PARAMS}}';
load();
});
</script>
</head>
<body>
</body>
}());
</script>
</head>
<body>
</body>
</html>
`
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment