Closed Bug 1589474 Opened 5 years ago Closed 1 year ago

The new performance panel icon in devtools should be highlighted in green when the profiler is running

Categories

(DevTools :: Performance Tools (Profiler/Timeline), enhancement, P3)

enhancement

Tracking

(firefox113 fixed)

RESOLVED FIXED
113 Branch
Tracking Status
firefox113 --- fixed

People

(Reporter: brennan.brisad, Assigned: ff2400t, Mentored)

Details

(Whiteboard: [devtools:relnote])

Attachments

(1 file, 9 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review

In the new performance panel in devtools (devtools.performance.new-panel-enabled set to true), the profiler icon (chrome://devtools/skin/images/tool-profiler.svg) in the tab bar is not highlighted in green when the profiler is running.

The old performance panel tab and the accessibility tab are both highlighted in green when they are running, so the new tab should probably have the same behavior.

Mentor: felash
Priority: -- → P3

Hi there, I would like to take on this bug. Could you give me some pointers as to how I would go about fixing it?

Flags: needinfo?(felash)

If I take the example of the Memory panel (it goes green when we check the option "record the call stacks"), this happens here: https://searchfox.org/mozilla-central/rev/cac340f10816707e91c46db6d285f80259420f07/devtools/client/framework/components/ToolboxTab.js#64
This means that to make the icon green, we need to add the id performance in this Set.
This is done by calling toolbox.highlightTool("performance"). See how the old panel is doing this too. I see it's done here: https://searchfox.org/mozilla-central/rev/cac340f10816707e91c46db6d285f80259420f07/devtools/client/performance/panel.js#108-114

In the new performance panel, the toolbox is accessible using the global gToolbox.

Now we need to see where we can call this. My suggestion is to create a react component, maybe called ToolboxHighlightController (suggestion). This component would get 2 prop:

  • the recordingState,
  • the toolbox
    It would render null, but in componentDidUpdate it would call toolbox.highlightTool or unhighlightTool depending on the value of the recordingState, and also comparing it with the previous value of the props (we have it as prevProps in the first argument of componentDidUpdate. Basically, if it's "recording" and the prevProps wasn't, we call highlightTool, and if it's not "recording" but prevProps was, we call unhighlightTool.

It would be rendered from Perf.js.

Now we need to take care also to one thing: depending on the context (depending whether the interface runs in the devtools' toolbox, or in the popup), the toolbox can be available, or absent. That's why I suggest to pass it as a prop to the component, so that the component doesn't have to check this. But this can be checked in Perf.js when the component is inserted, something like this:

gToolbox ? ToolboxHighlightController({ toolbox: gToolbox, recordingState }) : null

I hope it makes sense!
Please tell me if you need anymore information :)

Assignee: nobody → stensonj
Flags: needinfo?(felash)

Thanks for your reply. I just have a few questions before I start work on this.
Where would I create the toolboxHighlightController react component?
Also where is the Perf.js file? And where would I call that code towards the end of your comment in that file?
One final question: If i create this new component and pass in data through props and put the necessary code inside said component while rendering nothing, how will that change the the profiler icon in the tab bar?

Apologies for the mass of questions. Currently I am unsure how to complete this.

All the code for this panel is in devtools/client/performance-new. There's a subdirectory components that contains the React components for this panel. This is where you can create the new component, and where you'll find the file Perf.js.

One final question: If i create this new component and pass in data through props and put the necessary code inside said component while rendering nothing, how will that change the the profiler icon in the tab bar?

This is done because highlightTool will add the panel name to the Set that's used in the code that deals with the icon (see links to these bits of code in my previous comment).

Just to be extra clear: this bug isn't about the icon in the tab bar, but the icon in the devtools' tab bar.

Please tell me if you need anything more! I understand that this bug is a bit involved, so if you can't make it, it's fine, but please say it now :-) But I think you can do it!

Hi there, I believed I have solved the bug, but in a different way to how you have described.
I have added the code "gToolbox.highlightTool("performance")" inside the "handleProfilerStarting" function in the Perf.js file. This highlights the icon in the devtools' bar as green when the user clicks "Start recording". I have also added the code "gToolbox.unhighlightTool("performance")" in the "handleProfilerStopping" function so that when the user clicks "Stop and grab the recording" the icon is unhighlighted. Does this sound okay to you? From what I gather this is what you were aiming for, and requires less code.

Your approach works, but the problem with it is that if for some reason the recording state is changed in another location it won't get the result.
My proposal is more code but it's more correct and more future proof. Also it's more easily testable: small components with one responsibility makes it easier :-)
Hope that makes sense!

Hi again. I am currently working on implementing ToolboxHighlightController.js, although I am running into an issue when I go to require the ToolboxHighlightController.js file from the Perf.js file. I am running into an error that is telling me the module is not found? I have double checked I am requiring from the correct path and checked file names yet am still getting the error. The file also does not appear to show up when I call the command 'hg diff', so I was wondering if you could give me any idea with regards to what I'm doing wrong? Thanks

About hg diff, I believe that's because it's a new file, and you need to "add" it first with the command hg add.

I think you need to give me the exact lines and where the files are located :) Otherwise it's difficult to help you. Attaching a diff as an attachment to the bug would help too.

Attached image unknown.png (obsolete) —

Hi again, as can be seen from my attachment. Inside the Perf.js file I am requiring the ToolBoxHighlightController.js from its location in the files (as can be seen on the right). Yet I am getting an 'is not found' error when running the browser and showing the devtools window. Any ideas?

Attached file hgdiffOfIssue.txt (obsolete) —

See attached an hg diff containing my changes as well.

Ah, I believe you need to add the filename to the file moz.build in the components directory.
I think this is how our build system decides what to package inside Firefox.

The file is showing up and is not giving me errors now. Thank you. I'll start work on this now!

Hey Jacob, I'm not sure you've seen my message on your patch. I wanted to let you know that the planned refactoring has been done and that you can apply your good changes on top of the latest code that's currently in the repository mozilla-central.
Please tell me if you don't intend to move forward with this so that I can propose it to somebody else :-)
Thanks a lot !

Flags: needinfo?(stensonj)

Hi Julien, I dont intend to move forward with this.

Flags: needinfo?(stensonj)

Thanks.
Then this is now up for grabs!
Basically the existing patch from Jacob works fine but needs to be applied on the current code.

Assignee: stensonj → nobody

Hi Julien,
I am new to this project and want to work on this issue. I have read the whole comment thread and have some few questions. I forked mozilla-central but don't have Perf.Js in the dir. So, I guess I have to make new. RIght ? Or I have to make a new ToolboxHighlighterController.js

Assignee: nobody → amanv1999

Hey Aman, thanks for looking at this!
That's because Perf.js has been split in 2 components: ProfilerEventHandling.js and DevToolsAndPopup.js. The changes will need to be applied to these components instead. I can't look more precisely now but I think you should be able to find it yourself. Thanks!

Depends on D60300

Depends on D60303

Attachment #9120844 - Attachment is obsolete: true
Attachment #9120907 - Attachment is obsolete: true
Attachment #9121593 - Attachment is obsolete: true
Attachment #9121596 - Attachment is obsolete: true
Attachment #9121597 - Attachment is obsolete: true

The bug assignee didn't login in Bugzilla in the last 7 months.
:julienw, could you have a look please?
For more information, please visit auto_nag documentation.

Assignee: amanv1999 → nobody
Flags: needinfo?(felash)

It would still be good to do this.

Flags: needinfo?(felash)
Severity: normal → S3
Assignee: nobody → amanv1999
Status: NEW → ASSIGNED
Attachment #9111972 - Attachment is obsolete: true
Attachment #9122135 - Attachment is obsolete: true

The bug assignee is inactive on Bugzilla, so the assignee is being reset.

Assignee: amanv1999 → nobody
Status: ASSIGNED → NEW

hello, i would like to work on this can someone Assign this to me

Assignee: nobody → amanv1999
Attachment #9121597 - Attachment is obsolete: false
Status: NEW → ASSIGNED
Attachment #9121596 - Attachment is obsolete: false
Attachment #9121593 - Attachment is obsolete: false
Attachment #9120907 - Attachment is obsolete: false
Assignee: amanv1999 → nobody
Status: ASSIGNED → NEW

@Abhijeet Chawla: I see you're already assigned and provided a patch to bug 1731635, do you still want to look at this one? I believe you'll have to start from scratch, I can give some updated instructions if needed. Please tell me and I can assign it to you!

Assignee: nobody → amanv1999
Attachment #9122135 - Attachment is obsolete: false
Status: NEW → ASSIGNED
Attachment #9111972 - Attachment is obsolete: false
Attachment #9120844 - Attachment is obsolete: false

Added the ToolboxHighlightController.js to Highlighing when the Profiler is On

Assignee: amanv1999 → abhijeetchawla22
Attachment #9111972 - Attachment is obsolete: true
Attachment #9120844 - Attachment is obsolete: true
Attachment #9120907 - Attachment is obsolete: true
Attachment #9121593 - Attachment is obsolete: true
Attachment #9121596 - Attachment is obsolete: true
Attachment #9121597 - Attachment is obsolete: true
Attachment #9122135 - Attachment is obsolete: true
Attachment #9110687 - Attachment is obsolete: true
Attachment #9110691 - Attachment is obsolete: true
Pushed by jwajsberg@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/5c940bd02fe7
The new performance panel icon in devtools should be highlighted in green when the profiler is running r=julienw
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 113 Branch
Whiteboard: [devtools:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: