Closed Bug 1644795 Opened 4 years ago Closed 4 years ago

Expose the list of all nsIContentParent's to JS

Categories

(Core :: DOM: Content Processes, task, P3)

task

Tracking

()

RESOLVED FIXED
mozilla80
Fission Milestone M6b
Tracking Status
firefox80 --- fixed

People

(Reporter: ochameau, Assigned: ochameau)

References

Details

Attachments

(2 files)

DevTools currently inspects all content processes via a code similar to this:
https://searchfox.org/mozilla-central/rev/fac90408bcf52ca88a3dcd2ef30a379b68ab24e2/devtools/server/actors/descriptors/process.js#110-111

for (let i = 0; i < Services.ppmm.childCount; i++) {
  const processMessageManager = Services.ppmm.getChildAt(i);

I'm currently looking forward using JSProcessActors instead of message managers... but.
I've not found a way to iterate over all nsIContentParent instances.
I saw that typically, you would spawn a JSProcessActor via browsingContext.currentWindowGlobal.contentParent,
but that doesn't really allow iterating over all the ContentParents.

Nika suggested to me that we could probably expose them via sequence<nsIContentParent> getAllContentParents() on ChromeUtils.

Some more discussion coming from Matrix:

Gis: can we add it as a static thing on JSProcessActor, maybe? I mean, I know ChromeUtils is a dumping ground as it is, but... :)

nika Sure, that'd be fine too. I suggested ChromeUtils just because it's already where methods like registerWindowActor are, but I suppose those could be moved to JSWindowActor.registerActor(...) and JSProcessActor.registerActor as well.
getAllContentParents does feel like more of a ChromeUtils method, though, as it's technically getting the native ContentParent object, rather than something explicitly tied to JSProcessActors.
Something like JSProcessActor.getAllActors("MyActorType") which calls getActor on every content process could work too.

This is a feature request from Frontend team.

Tracking for Fission Nightly M6b

Type: enhancement → task
Fission Milestone: --- → M6b
Priority: -- → P3
Blocks: 1648499
Assignee: nobody → poirot.alex
Status: NEW → ASSIGNED

I went for ChromeUtils.getAllContentParents() as it better matches current DevTools needs over here:
https://searchfox.org/mozilla-central/rev/a87a1c3b543475276e6d57a7a80cb02f3e42b6ed/devtools/server/actors/process.js#23-34
We have to know about all the process and their OS PIDs. JSProcessActors / JSProcessActor.getAllActors("MyActorType") won't help provide this information.

And later on, we need to connect to one specific content process, again JSProcessActor.getAllActors("MyActorType") won't help,
while we can iterate over ChromeUtils.getAllContentParents() in order to find the matching osPid.

See https://phabricator.services.mozilla.com/D81123 where I sketched something to demonstrate how we would use such APIs.
This patch doesn't work, it is purely theoritical. I have a few things to address (bug 1620248) before getting to this.

Attachment #9159340 - Attachment description: Bug 1644795 - Expose ContentParents via ChromeUtils.getAllContentParents(). → Bug 1644795 - Expose all nsIDOMProcessParent via ChromeUtils.getAllDOMProcesses().
Attachment #9159341 - Attachment description: Bug 1644795 - Expose OS Pid on nsIContentParent. → Bug 1644795 - Expose OS Pid on nsIDOMProcessParent.
Pushed by apoirot@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7cc7ff20205e Expose all nsIDOMProcessParent via ChromeUtils.getAllDOMProcesses(). r=nika https://hg.mozilla.org/integration/autoland/rev/9cf50d4ea19f Expose OS Pid on nsIDOMProcessParent. r=nika
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: