Closed Bug 1644795 Opened 2 months ago Closed 1 month ago

Expose the list of all nsIContentParent's to JS


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




Fission Milestone M6b
Tracking Status
firefox80 --- fixed


(Reporter: ochameau, Assigned: ochameau)


(Blocks 1 open bug)



(2 files)

DevTools currently inspects all content processes via a code similar to this:

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

I went for ChromeUtils.getAllContentParents() as it better matches current DevTools needs over here:
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 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
Expose all nsIDOMProcessParent via ChromeUtils.getAllDOMProcesses(). r=nika
Expose OS Pid on nsIDOMProcessParent. r=nika
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
You need to log in before you can comment on or make changes to this bug.