From 8072e8c62b3efe2cf2c49dd404226a163e811362 Mon Sep 17 00:00:00 2001 From: Alexandre Poirot Date: Thu, 24 Mar 2022 21:03:41 +0000 Subject: [PATCH] Bug 1719615 - [devtools] Enable 'observeWasm' only once the debugger is opened. r=yury,bomsy Because WASM debugging triggers different machine code with debugging instruction, the memory usage very significantly increase. So avoid enabling it until the debugger is opened. Differential Revision: https://phabricator.services.mozilla.com/D140069 --- .../client/debugger/src/client/firefox.js | 22 +++++++++++++------ devtools/client/shared/thread-utils.js | 1 - devtools/server/actors/utils/make-debugger.js | 6 +++++ 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/devtools/client/debugger/src/client/firefox.js b/devtools/client/debugger/src/client/firefox.js index afdaccb1b702..24ba27834732 100644 --- a/devtools/client/debugger/src/client/firefox.js +++ b/devtools/client/debugger/src/client/firefox.js @@ -43,13 +43,21 @@ export async function onConnect(_commands, _resourceCommand, _actions, store) { } await targetCommand.startListening(); } - // `pauseWorkersUntilAttach` is one option set when the debugger panel is opened rather that from the toolbox. - // The reason is to support early breakpoints in workers, which will force the workers to pause - // and later on (when TargetMixin.attachThread is called) resume worker execution, after passing the breakpoints. - // We only observe workers when the debugger panel is opened (see the few lines before and listenForWorkers = true). - // So if we were passing `pauseWorkersUntilAttach=true` from the toolbox code, workers would freeze as we would not watch - // for their targets and not resume them. - const options = { pauseWorkersUntilAttach: true }; + + const options = { + // `pauseWorkersUntilAttach` is one option set when the debugger panel is opened rather that from the toolbox. + // The reason is to support early breakpoints in workers, which will force the workers to pause + // and later on (when TargetMixin.attachThread is called) resume worker execution, after passing the breakpoints. + // We only observe workers when the debugger panel is opened (see the few lines before and listenForWorkers = true). + // So if we were passing `pauseWorkersUntilAttach=true` from the toolbox code, workers would freeze as we would not watch + // for their targets and not resume them. + pauseWorkersUntilAttach: true, + + // Bug 1719615 - Immediately turn on WASM debugging when the debugger opens. + // We avoid enabling that as soon as DevTools open as WASM generates different kind of machine code + // with debugging instruction which significantly increase the memory usage. + observeWasm: true, + }; await commands.threadConfigurationCommand.updateConfiguration(options); // We should probably only pass descriptor informations from here diff --git a/devtools/client/shared/thread-utils.js b/devtools/client/shared/thread-utils.js index 60305fb24203..1aa8a98aafc7 100644 --- a/devtools/client/shared/thread-utils.js +++ b/devtools/client/shared/thread-utils.js @@ -43,7 +43,6 @@ exports.getThreadOptions = async function() { ), // This option is always true. See Bug 1654590 for removal. observeAsmJS: true, - observeWasm: true, breakpoints: sanitizeBreakpoints(await asyncStore.pendingBreakpoints), // XXX: `event-listener-breakpoints` is a copy of the event-listeners state // of the debugger panel. The `active` property is therefore linked to diff --git a/devtools/server/actors/utils/make-debugger.js b/devtools/server/actors/utils/make-debugger.js index 0f9d45bef264..b52b5939f255 100644 --- a/devtools/server/actors/utils/make-debugger.js +++ b/devtools/server/actors/utils/make-debugger.js @@ -61,8 +61,14 @@ module.exports = function makeDebugger({ const dbg = new Debugger(); EventEmitter.decorate(dbg); + // By default, we disable asm.js and WASM debugging because of performance reason. + // Enabling asm.js debugging (allowUnobservedAsmJS=false) will make asm.js fallback to JS compiler + // and be debugging as a regular JS script. dbg.allowUnobservedAsmJS = true; + // Enabling WASM debugging (allowUnobservedWasm=false) will make the engine compile WASM scripts + // into different machine code with debugging instructions. This significantly increase the memory usage of it. dbg.allowUnobservedWasm = true; + dbg.uncaughtExceptionHook = reportDebuggerHookException; const onNewGlobalObject = function(global) {