Closed Bug 1570242 Opened 5 years ago Closed 5 years ago

Stop memoizing the target object in WebConsole classes

Categories

(DevTools :: Console, enhancement, P1)

enhancement

Tracking

(Fission Milestone:M6c, firefox70 fixed)

RESOLVED FIXED
Firefox 70
Fission Milestone M6c
Tracking Status
firefox70 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

(Whiteboard: dt-fission-m2-mvp)

Attachments

(3 files)

The WebConsole and WebConsoleConnectionProxy classes are memoizing the target front.
But this get in the way of bug 1565263.

Instead, we should fetch the target from a dynamic getter, so that we always get "the current target", instead of "whatever target the toolbox was opened with".

An alternative could be to update this memoized target attribute whenever the toolbox switchs to another target, but is it any better?

A third option could be to emit a "this target is about to be replaced by this new one" on the target itself, and listen to it everywhere, from the toolbox and panels. But we might have an ordering issue. As of today, the toolbox do call target.attach(), and for now, we expect it to be called first before the panel start using the target object. An example is target.activeConsole that is only set after attach resolves. There might be other cases like that. As part of the resource API discussion, we might inline the call to attach into the instantiation of the target actors and so this may no longer be an issue.

As we enable fission and support more than one target, the target will change and so memoizing gets in the way.
I see three options here:

  • always fetch the target from toolbox, which watch for target changes, attach the new one (this is necessary to have activeConsole working)
  • listen for "switch-target" on toolbox in order to update the memoized target everywhere in console. We should probably stop memoizing it everywhere but one high level class
  • try to emit a "switching to another target" on the TargetMixin, listen to that and do similarly to the previous option.

This patch applies the first option.

Priority: -- → P2

Do that to better highlight that the target can change over time.

Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/a213b28dd40f
Fetch target from toolbox instead of memoizing it on console classes. r=nchevobbe
https://hg.mozilla.org/integration/autoland/rev/304366165980
Fetch toolbox from WebConsole class rather than gDevTools. r=nchevobbe
https://hg.mozilla.org/integration/autoland/rev/854e62f7f1ae
Rename target to currentTarget in WebConsole codebase. r=nchevobbe,yulia

This should fix the test failure:

diff --git a/devtools/client/webconsole/test/node/components/webconsole-wrapper.test.js b/devtools/client/webconsole/test/node/components/webconsole-wrapper.test.js
--- a/devtools/client/webconsole/test/node/components/webconsole-wrapper.test.js
+++ b/devtools/client/webconsole/test/node/components/webconsole-wrapper.test.js
@@ -22,7 +22,7 @@ const { messagesAdd } = require("devtool
 
 async function getWebConsoleWrapper() {
   const hud = {
-    target: { client: {}, getFront: () => {} },
+    currentTarget: { client: {}, getFront: () => {} },
     getMappedExpression: () => {},
   };
   const webConsoleUi = getWebConsoleUiMock(hud);

Pushed by apoirot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1e3b87887a98
Fetch target from toolbox instead of memoizing it on console classes. r=nchevobbe
https://hg.mozilla.org/integration/autoland/rev/d5edaef8eff0
Fetch toolbox from WebConsole class rather than gDevTools. r=nchevobbe
https://hg.mozilla.org/integration/autoland/rev/ecdbc6266c47
Rename target to currentTarget in WebConsole codebase. r=nchevobbe,yulia
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 70
Whiteboard: dt-fission-m2-mvp
Priority: P2 → P1

Tracking dt-fission-m2-mvp bugs for Fission Nightly milestone (M6c)

Fission Milestone: --- → M6c
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: