Open Bug 1530822 Opened 5 years ago Updated 2 years ago

netmonitor/src/api.js and all its dependencies are loaded twice in a row


(DevTools :: Netmonitor, defect, P3)



(Not tracked)


(Reporter: florian, Unassigned)


(Blocks 1 open bug)


(Keywords: perf)

See this profile:

This issue is about the devtools loaders, with an s, because we have two loaders in the game here.

We load the api module once from toolbox here:
This one load uses the DevTools loader. A loader that loads module once for all, and is never destroyed, nor attached to any particular context/document.

And we then load it from the netmonitor panel here:
This time this is loaded via the Browser loader instance of the netmonitor panel. This loader is very different as it is bound to the panel lifecycle. Whenever the panel is closed (when the toolbox closes), this loader will be destroyed. Also it is bound to the netmonitor document so that modules can have access to document and window globals. We typically use this loader for react modules which have to have access to the panel's document via globals.

This module is loaded via the browser loader from initializer based on the module location and the netmonitor browser loader parameters:

const require = window.windowRequire = BrowserLoader({
  baseURI: "resource://devtools/client/netmonitor/",
const { NetMonitorAPI } = require("./src/api");

The baseURI parameter defines that all modules from this netmonitor folder will be loaded by the BrowserLoader, while any other one will be loaded via the DevTools loader.
(Well it is slightly more complex, as they is also this white list of folders to be going throught the browser loader:

So to address the issue here, we should either tune baseURI parameter and/or move api.js

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.