author | Alexandre Poirot <poirot.alex@gmail.com> |
Mon, 31 May 2021 20:29:55 +0000 | |
changeset 581531 | 90d2e0a0ead6aaab6dfaadb53a5354b22a94f681 |
parent 581530 | 8967dc205c2191c67b30baa1960b842861292a8c |
child 581532 | 3e18373a945ff09b23c4b71d26c5aa0d60195d1f |
push id | 144084 |
push user | apoirot@mozilla.com |
push date | Mon, 31 May 2021 20:32:33 +0000 |
treeherder | autoland@f7988048b5d7 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nchevobbe |
bugs | 1702511 |
milestone | 91.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/devtools/client/webconsole/webconsole-ui.js +++ b/devtools/client/webconsole/webconsole-ui.js @@ -144,26 +144,47 @@ class WebConsoleUI { */ init() { if (this._initializer) { return this._initializer; } this._initializer = (async () => { this._initUI(); - // Bug 1605763: It's important to call _attachTargets once the UI is initialized, as - // TargetCommand.startListening will start fetching additional targets - // and may overload the Browser Console. - await this._attachTargets(); + + if (this.isBrowserConsole) { + // Bug 1605763: + // TargetCommand.startListening will start fetching additional targets + // and may overload the Browser Console with loads of targets and resources. + // We can call it from here, as `_attachTargets` is called after the UI is initialized. + // Bug 1642599: + // TargetCommand.startListening has to be called before: + // - `_attachTargets`, in order to set TargetCommand.watcherFront which is used by ResourceWatcher.watchResources. + // - `ConsoleCommands`, in order to set TargetCommand.targetFront which is wrapped by hud.currentTarget + await this.hud.commands.targetCommand.startListening(); + } this._consoleCommands = new ConsoleCommands({ commands: this.hud.commands, }); await this.wrapper.init(); + + // Bug 1605763: It's important to call _attachTargets once the UI is initialized, as + // it may overload the Browser Console with many updates. + // It is also important to do it only after the wrapper is initialized, + // otherwise its `store` will be null while we already call a few dispatch methods + // from onResourceAvailable + await this._attachTargets(); + + // `_attachTargets` will process resources and throttle some actions + // Wait for these actions to be dispatched before reporting that the + // console is initialized. Otherwise `showToolbox` will resolve before + // all already existing console messages are displayed. + await this.wrapper.waitAsyncDispatches(); })(); return this._initializer; } destroy() { if (!this.hud) { return; @@ -326,27 +347,16 @@ class WebConsoleUI { * * @private * @return object * A promise object that is resolved/reject based on the proxies connections. */ async _attachTargets() { this.additionalProxies = new Map(); - if (this.isBrowserConsole) { - // Bug 1605763: - // TargetCommand.startListening will start fetching additional targets - // and may overload the Browser Console with loads of targets and resources. - // We can call it from here, as `_attchTargets` is called after the UI is initialized. - // Bug 1642599: - // TargetCommand.startListening ought to be called before watching for resources, - // in order to set TargetCommand.watcherFront which is used by ResourceCommand.watchResources. - await this.hud.commands.targetCommand.startListening(); - } - // Listen for all target types, including: // - frames, in order to get the parent process target // which is considered as a frame rather than a process. // - workers, for similar reason. When we open a toolbox // for just a worker, the top level target is a worker target. // - processes, as we want to spawn additional proxies for them. await this.hud.commands.targetCommand.watchTargets( this.hud.commands.targetCommand.ALL_TYPES,