UI: Build wasm with -g2 to preserve symbols, fix OOM message
The previous emscripten+wasm toolchain roll broke C++ symbols
in Wasm crashes and, recursively, the special casing around
known crashes (e.g. OOM).
This CL:
- Adds -g2 to preserve function names, now explicitly required
when building with -O3.
- Adds ASSERTIONS=1 (1 in debug builds) to get the error message
("cannot enlarge memory") from OOMs.
- Tweaks the OOM detection code, as the message slightly changed
(it doesn't mention "array" anymore).
- Makes the OOM message a bit more actionable.
Bug: 182711686
Bug: 181218057
Bug: 181237261
Change-Id: I84909f08bd2d93b4545cd5f0a5e29f94dd126bee
diff --git a/gn/standalone/wasm.gni b/gn/standalone/wasm.gni
index a66b34b..bcf952b 100644
--- a/gn/standalone/wasm.gni
+++ b/gn/standalone/wasm.gni
@@ -72,9 +72,23 @@
"-lworkerfs.js", # For FS.filesystems.WORKERFS
]
if (is_debug) {
- _target_ldflags += [ "-g4" ]
+ _target_ldflags += [
+ "-s",
+ "ASSERTIONS=2",
+ "-s",
+ "SAFE_HEAP=1",
+ "-s",
+ "STACK_OVERFLOW_CHECK=1",
+ "-g4",
+ "-O0",
+ ]
} else {
- _target_ldflags += [ "-O3" ]
+ _target_ldflags += [
+ "-s",
+ "ASSERTIONS=1",
+ "-g2", # Required for getting C++ symbol names.
+ "-O3",
+ ]
}
if (defined(invoker.js_library)) {
diff --git a/ui/src/frontend/error_dialog.ts b/ui/src/frontend/error_dialog.ts
index 87195b8..9fba9a0 100644
--- a/ui/src/frontend/error_dialog.ts
+++ b/ui/src/frontend/error_dialog.ts
@@ -34,7 +34,7 @@
const now = performance.now();
// Here we rely on the exception message from onCannotGrowMemory function
- if (errLog.includes('Cannot enlarge memory arrays')) {
+ if (errLog.includes('Cannot enlarge memory')) {
showOutOfMemoryDialog();
// Refresh timeLastReport to prevent a different error showing a dialog
timeLastReport = now;
@@ -185,19 +185,26 @@
function showOutOfMemoryDialog() {
const url =
'https://perfetto.dev/docs/quickstart/trace-analysis#get-trace-processor';
- const description = 'This is a limitation of your browser. ' +
- 'You can get around this by loading the trace ' +
- 'directly in the trace_processor binary.';
+ const tpCmd = 'curl -LO https://get.perfetto.dev/trace_processor\n' +
+ 'chmod +x ./trace_processor\n' +
+ 'trace_processor --httpd /path/to/trace.pftrace\n' +
+ '# Reload the UI, it will prompt to use the HTTP+RPC interface';
showModal({
title: 'Oops! Your WASM trace processor ran out of memory',
content: m(
'div',
- m('span', description),
+ m('span',
+ 'The in-memory representation of the trace is too big ' +
+ 'for the browser memory limits (typically 2GB per tab).'),
+ m('br'),
+ m('span',
+ 'You can work around this problem by using the trace_processor ' +
+ 'native binary as an accelerator for the UI as follows:'),
m('br'),
m('br'),
- m('span', 'Example command:'),
- m('.modal-bash', '> trace_processor trace.pftrace --http'),
+ m('.modal-bash', tpCmd),
+ m('br'),
m('span', 'For details see '),
m('a', {href: url, target: '_blank'}, url),
),
diff --git a/ui/src/frontend/index.ts b/ui/src/frontend/index.ts
index fef5661..553b830 100644
--- a/ui/src/frontend/index.ts
+++ b/ui/src/frontend/index.ts
@@ -285,7 +285,7 @@
'object-src': ['none'],
'connect-src': [
`'self'`,
- 'http://127.0.0.1:9001', // For trace_processor_shell --http.
+ 'http://127.0.0.1:9001', // For trace_processor_shell --httpd.
'https://www.google-analytics.com',
'https://*.googleapis.com', // For Google Cloud Storage fetches.
'blob:',