1<!doctype html>
2<html lang="en-us">
3<head>
4  <meta charset="utf-8">
5  <title>Perfetto UI</title>
6  <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
7  <link rel="shortcut icon" id="favicon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=">
8</head>
9<body data-perfetto_version='{"filled_by_build_js":"."}'>
10  <!--
11    Don't add any content here. The whole <body> is replaced by
12    frontend/index.ts when bootstrapping. This is only used for very early
13    error reporting.
14  -->
15  <style>
16  #app_load_failure {opacity:0;transition:opacity 1s ease;position:absolute;background:#080082;top:0;left:0;width:100%;height:100%;bottom:0;right:0;margin:0;opacity:0;user-select:text}
17  #app_load_failure > pre {color:#fff;position:absolute;margin:auto;white-space:pre-wrap;top:50%;transform:translate(0,-50%);max-width:90vw;width:880px;left:0;right:0;font-size:16px;line-height:30px;font-weight:700}
18  #app_load_failure > pre span {background:#fff;color:#080082;padding:2px}
19  #app_load_failure a {color:#fff}
20  #app_load { position: absolute; top: 0; left: 0; right:0; bottom: 0; background-color: #2c3e50;}
21  #app_load_spinner { margin: 30vh auto; width: 150px; height: 150px; border: 3px solid rgba(255,255,255,.3); border-radius: 50%; border-top-color: #fff; animation: app_load_spin 1s ease-in-out infinite; }
22  @keyframes app_load_spin { to { transform: rotate(360deg); } }
23  </style>
24  <div id="app_load"><div id="app_load_spinner"></div></div>
25  <div id="app_load_failure">
26<pre>
27<span>Perfetto UI - An unrecoverable problem occurred</span>
28
29If you are seeing this message, something went wrong while loading the UI.
30Please file a bug (details below) and try these remediation steps:
31
32* Force-reload the page with Ctrl+Shift+R (Mac: Meta+Shift+R) or
33  Shift + click on the refresh button.
34
35* <a href="javascript:clearAllCaches();">Click here</a> to clear all the site storage and caches and reload the page.
36
37* Clear the site data and caches from devtools, following <a target="_blank" href="https://developers.google.com/web/tools/chrome-devtools/storage/cache#deletecache">these instructions</a>.
38
39* If neither of these work, you can use an old fallback instance hosted at
40  <a target="_blank" href="https://staging-dot-perfetto-ui.appspot.com">staging-dot-perfetto-ui.appspot.com</a>
41
42In any case, **FILE A BUG** attaching logs and screenshots from devtools.
43  Googlers:      <a href="http://go/perfetto-ui-bug" target="_blank">go/perfetto-ui-bug</a>
44  Non-googlers:  <a href="https://github.com/google/perfetto/issues/new" target="_blank">github.com/google/perfetto/issues/new</a>
45
46<div id=app_load_failure_err></div>
47Technical Information:
48<div id=app_load_failure_dbg></div>
49</pre>
50  </div>
51  <script type="text/javascript">
52    'use strict';
53    (function () {
54      const TIMEOUT_MS = 20000;
55      let errTimerId = undefined;
56
57      function errHandler(err) {
58        // Note: we deliberately don't clearTimeout(), which means that this
59        // handler is called also in the happy case when the UI loads. In that
60        // case, though, the onCssLoaded() in frontend/index.ts will empty the
61        // <body>, so |div| below will be null and this function becomes a
62        // no-op.
63        const div = document.getElementById('app_load_failure');
64        if (!div) return;
65        div.style.opacity ='1';
66        const errDom = document.getElementById('app_load_failure_err');
67        if (!errDom) return;
68        console.error(err);
69        errDom.innerText += `${err}\n`;
70        const storageJson = JSON.stringify(window.localStorage);
71        const dbg = document.getElementById('app_load_failure_dbg');
72        if (!dbg) return;
73        dbg.innerText = `LocalStorage: ${storageJson}\n`;
74        if (errTimerId !== undefined) clearTimeout(errTimerId);
75      }
76
77      // For the 'Click here to clear all caches'.
78      window.clearAllCaches = () => {
79        if (window.localStorage) window.localStorage.clear();
80        if (window.sessionStorage) window.sessionStorage.clear();
81        const promises = [];
82        if (window.caches) {
83          window.caches.keys().then(
84            keys => keys.forEach(k => promises.push(window.caches.delete(k))));
85        }
86        if (navigator.serviceWorker) {
87          navigator.serviceWorker.getRegistrations().then(regs => {
88            regs.forEach(reg => promises.push(reg.unregister()));
89          });
90        }
91        Promise.all(promises).then(() => window.location.reload());
92      }
93
94      // If the frontend doesn't come up, make the error page above visible.
95      errTimerId = setTimeout(() => errHandler('Timed out'), TIMEOUT_MS);
96      window.onerror = errHandler;
97      window.onunhandledrejection = errHandler;
98
99      const versionStr = document.body.dataset['perfetto_version'] || '{}';
100      const versionMap = JSON.parse(versionStr);
101      const channel = localStorage.getItem('perfettoUiChannel') || 'stable';
102
103      // The '.' below is a fallback for the case of opening a pinned version
104      // (e.g., ui.perfetto.dev/v1.2.3./). In that case, the index.html has no
105      // valid version map; we want to load the frontend from the same
106      // sub-directory directory, hence ./frontend_bundle.js.
107      const version = versionMap[channel] || versionMap['stable'] || '.';
108
109      const script = document.createElement('script');
110      script.async = true;
111      script.src = version + '/frontend_bundle.js';
112      script.onerror = () => errHandler(`Failed to load ${script.src}`);
113
114      document.head.append(script);
115    })();
116  </script>
117</body>
118</html>
119