Closed Bug 1771088 Opened 2 years ago Closed 2 years ago

Modules are loaded many times and many loader are instantiated when debugging system principals

Categories

(DevTools :: Framework, defect)

defect

Tracking

(firefox103 fixed)

RESOLVED FIXED
103 Branch
Tracking Status
firefox103 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

(Blocks 1 open bug)

Details

Attachments

(3 files)

The following code is instantiating one Loader per DevToolsFrameChild instance:
https://searchfox.org/mozilla-central/rev/9902932742fcdce2c956eeb81fd38350f5394ab2/devtools/server/connectors/js-window-actor/DevToolsFrameChild.jsm#319-323

    this.useCustomLoader = this.document.nodePrincipal.isSystemPrincipal;
      this.loader = this.useCustomLoader
        ? new Loader.DevToolsLoader({
            invisibleToDebugger: true,
          })
        : Loader;

This only happens when debugging system principal documents.

This typically happens when opening the Browser Toolbox, where we will load actors once per WindowGlobal.

We were instantiating one new Loader per DevToolsFrameChild instance.
This patch tries to share this loader with all the instances as well as share it
with the one used to load DevToolsServer when we are running in the parent process.

Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED

This rule was matching any function prefixed with use, even in modules
that weren't React components.
In addition to that, DevTools aren't using React hooks, so this rule is uncessary.

This helps simplify DevToolsFrameChild and avoid registering and not leaking a connectionchange listener.

This also help always nullify this.loader in DevToolsFrameChild.
For some reason, the first time didDestroy is called, there is still another connection registered in the server.

Blocks: 1092821
No longer blocks: 1651849
Blocks: 1772146
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7d217a3bec55 [devtools] Disable react-hooks/rules-of-hooks eslint rule. r=jdescottes https://hg.mozilla.org/integration/autoland/rev/713a550b2bf1 [devtools] Move the server destruction code to DevToolsServer. r=jdescottes https://hg.mozilla.org/integration/autoland/rev/6f3b3d8024c3 [devtools] Ensure instantiating only one Loader when debugging the system principal. r=jdescottes
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → 103 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: