Closed Bug 1545283 Opened 7 years ago Closed 3 years ago

Convert Troubleshoot.jsm to use ChromeUtils.requestProcInfo over Services.ppmm to get process types

Categories

(Toolkit :: General, task, P5)

64 Branch
task

Tracking

()

RESOLVED FIXED
114 Branch
Tracking Status
firefox114 --- fixed

People

(Reporter: Felipe, Assigned: imlata1111, Mentored)

References

Details

(Keywords: good-first-bug, Whiteboard: [lang=js])

Attachments

(2 files)

In bug 1505322, a detailed list of remote processes was added to about:support. However, the list is incomplete, as it only covers the processes related to web content + manually covers the GPU process.

There's the ChromeUtils.requestProcInfo API, but it was brand new, and I wasn't sure if it was ready and stable to be used from about:support. (It calls into a lot of proc and thread-related C++ code and opening about:support is definitely not a good moment to crash users)

However, if we 're confident in it, and assuming new processes will be added to requestProcInfo, about:support will remain up to date with new things.

When we do that, we should add translations for the other proc types to the file processTypes.ftl

Type: enhancement → task
Priority: -- → P3
Mentor: mconley
Severity: normal → N/A
Keywords: good-first-bug
Priority: P3 → P5
Summary: Convert about:support Remote Processes breakdown to use ChromeUtils.requestProcInfo → Convert Troubleshoot.jsm to use ChromeUtils.requestProcInfo over Services.ppmm to get process types
Whiteboard: [lang=js]

Hey guys, I would like to work on this. It's my first bug fix here, but I'm a experienced js dev.
I think I'll need a little bit more info from the mentor re where in the code base to start looking.

Flags: needinfo?(mconley)

Hi, Sam!

Thanks for volunteering to hack on this bug. I can definitely help you get started, but before I assign this bug to you, I wanted to check a few things:

  1. Do you have a local clone of the repository already?
  2. Have you managed to build Firefox locally and get it running?

If so, I can get you started on this bug and point you in the right direction.

Flags: needinfo?(mconley) → needinfo?(samrat.shiwakoti)

Hi Mike,
Thanks for getting back.
Yes for both 1 and 2.

I went ahead and just changed Services.ppmm to Chromeutils.requestProcInfo in here:
https://searchfox.org/mozilla-central/source/toolkit/modules/Troubleshoot.jsm

I couldn't find info on what requestProcInfo returns however, so will need your help on that one. Need to see if childCount and getChildAt would still work.

Thanks,
Sam

Flags: needinfo?(samrat.shiwakoti)

Hi Sam!

So the requestProcInfo method is defined here in the ChromeUtils WebIDL file: https://searchfox.org/mozilla-central/rev/4f4c8e0e84d5a728244f1e820dda14e5cdb81e71/dom/chrome-webidl/ChromeUtils.webidl#535-539

You're not going to get a childCount or getChildAt from that, but that's okay - it returns a Promise that resolves to a ParentProcInfoDictionary, which is defined here: https://searchfox.org/mozilla-central/rev/4f4c8e0e84d5a728244f1e820dda14e5cdb81e71/dom/chrome-webidl/ChromeUtils.webidl#768-801

From that, we can iterate the children of the top-level of that dictionary, where each entry will be a ChildProcInfoDictionary: https://searchfox.org/mozilla-central/rev/4f4c8e0e84d5a728244f1e820dda14e5cdb81e71/dom/chrome-webidl/ChromeUtils.webidl#726-766

so the "type" is what we're most interested in, and what we can poke into the remoteTypes here: https://searchfox.org/mozilla-central/rev/4f4c8e0e84d5a728244f1e820dda14e5cdb81e71/toolkit/modules/Troubleshoot.jsm#413-417

Also note that we can remove this call to remoteTypePrefix here: https://searchfox.org/mozilla-central/rev/4f4c8e0e84d5a728244f1e820dda14e5cdb81e71/toolkit/modules/Troubleshoot.jsm#411, since requestProcInfo automatically truncates the domain from the process type.

Let me know if you have any questions, I'm happy to answer.

Assignee: nobody → samrat.shiwakoti
Flags: needinfo?(samrat.shiwakoti)

Hey, thanks for the detailed explanation. I have enough info to start on this, and the definitions in the webidl file makes this straightforward.
I still haven't figured out how I can test this / log or use breakpoints on this while working on it. But I'll try to figure that out, and if I can't, I'll let you know.

Thanks

Flags: needinfo?(samrat.shiwakoti)

Hey Sam, just checking in to see how it's going. Any questions for me?

Flags: needinfo?(samrat.shiwakoti)

Hey Mike,
I have the code ready via reading the documentation, but still haven't figured out how to test.

# HG changeset patch
# User samratrocks
# Date 1662076388 14400
#      Thu Sep 01 19:53:08 2022 -0400
# Branch bugfix-1545283
# Node ID 5894774eceb26e20d8b1e9697e881cdcd2eb7cc3
# Parent  af1fc1e6eb24573a5ebad1754b9d4917e934a5f9
Convert Troubleshoot.jsm to use ChromeUtils.requestProcInfo over Services.ppmm

diff -r af1fc1e6eb24 -r 5894774eceb2 toolkit/modules/Troubleshoot.jsm
--- a/toolkit/modules/Troubleshoot.jsm	Thu Sep 01 00:53:00 2022 +0300
+++ b/toolkit/modules/Troubleshoot.jsm	Thu Sep 01 19:53:08 2022 -0400
@@ -393,13 +393,15 @@
     );
   },
 
-  processes: function processes(done) {
+  processes: async function processes(done) {
     let remoteTypes = {};
 
-    for (let i = 0; i < Services.ppmm.childCount; i++) {
+    const processInfo = await ChromeUtils.requestProcInfo();
+
+    for (let i = 0; i < processInfo.children.length; i++) {
       let remoteType;
       try {
-        remoteType = Services.ppmm.getChildAt(i).remoteType;
+        remoteType = processInfo[i].type;
       } catch (e) {}
 
       // The parent process is also managed by the ppmm (because
@@ -408,8 +410,6 @@
         continue;
       }
 
-      remoteType = E10SUtils.remoteTypePrefix(remoteType);
-
       if (remoteTypes[remoteType]) {
         remoteTypes[remoteType]++;
       } else {

Also need to figure out Mercurial a little bit more.

Flags: needinfo?(samrat.shiwakoti)

[update to comment above]:

processInfo.children[i].type;

Update on this,
I was able to go start testing. Didn't realize the log was in the terminal and not the dev tool console .
Will let you know if there are any questions.
Thanks!

Hey Mike,
I have submitted PR for this:
https://phabricator.services.mozilla.com/D156610

Ty!

This good-first-bug hasn't had any activity for 2 months, it is automatically unassigned.
For more information, please visit auto_nag documentation.

Assignee: samrat.shiwakoti → nobody

Hello, I can please get assigned to this. Thank you :)

Hey Mike! I'm an outreachy applicant and interested in solving this bug. Since there is a patch already attached to this. How should I continue by making the changes in the previous patch or submitting a new one?

Hi Lata and akanksha.t05,

Sorry that I didn't jump on this more quickly! Since akanksha.t05 asked first, I'm going to assign them the bug to work on. Yes, akanksha.t05, the starting point would be trying to apply the original patch and then if it applies cleanly, addressing the remaining review comments from the Phabricator revision. Let me know if you need any guidance on doing that.

Assignee: nobody → akanksha.t05

Hey Mike! Since we didn't hear anything from akanksha.t05. Can I work on this now?

Flags: needinfo?(mconley)

Hi Lata,

My spologies for not getting back sooner. Yes, we haven't heard from akanksha.t05, so this is fine for you to work on. Thanks!

Flags: needinfo?(mconley)
Assignee: akanksha.t05 → nobody

Thank you! I am working on this and soon submit a revised patch.

Assignee: nobody → imlata1111
Status: NEW → ASSIGNED

Hey Mike! I have submitted the revised patch. I couldn't make changes to the existing patch as Troubleshoot.jsm has changed to Troubleshoot.sys.mjs and that was giving error while applying the changes. Kindly review my new patch and let me know if any further changes has to be made.

Pushed by mconley@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/8b969a3872ea Convert Troubleshoot.jsm to use ChromeUtils.requestProcInfo over Services.ppmm to get process types. r=mconley
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 114 Branch
Regressions: 1863952
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: