Ported profiler to a WebExtension #44
Conversation
|
The keyboard shortcut change is unfortunate. It would be really good to find a way to avoid it. |
|
In terms of updates, updating an SDK-based add-on to a WebExtension seems to be no problem at all - we just need to point the update.rdf file at a different URL. However, it's not possible to update to an add-on with a different ID. So either we need to keep the ID
|
|
What is the reason for wanting to change the ID? |
|
@mozilla.com and @mozilla.org IDs have special protections on AMO, and the profiler API is currently protected by a whitelist of APIs that can access it. I really don't want to add a jid0-a-bunch-of-nonsense@jetpack ID to that list. |
|
It's easy enough to add one or two add-ons to the list on AMO. I'm assuming that the hard coding of ids is a temporary solution until we've got a unified solution coming out of https://bugzilla.mozilla.org/show_bug.cgi?id=1280235. If not, wouldn't mind talking about that more so we don't end up with competing systems. |
|
Yes, it's meant as a temporary solution, but at this point, getting the profiler off of the SDK is too important to block on that. |
|
Awesome, all cool with me then. |
- gecko_profiler.xpi just points to the old SDK-based add-on. - gecko_profiler-0.1.xpi points to the new WebExtension. In order to transition, we'll just need to pull the files from the transition folder into the root folder, overwriting the update.rdf file with the one from transition.
|
I updated the commit to leave the old xpi and update.rdf files intact, but created a new directory called transtion. This has the code as outlined above to install a temporary add-on which will simply try to install the new add-on and, if successful, uninstall itself. Unfortunately I'm still stuck on the keyboard shortcut issue. |
These won't be needed until we are trying to support remote profiling.
| @@ -1,25 +0,0 @@ | |||
| <!DOCTYPE html> | |||
mstange
Apr 28, 2017
Contributor
I would like to keep this file around because it helps when playing with the popup design.
I would like to keep this file around because it helps when playing with the popup design.
| @@ -33,7 +22,6 @@ function renderState(state) { | |||
| document.querySelector('.relevancy-level-fill').style.width = `${information * 100}%`; | |||
|
|
|||
| const height = document.body.getBoundingClientRect().height; | |||
| self.port.emit('ProfilerControlEvent', { type: 'PanelHeightUpdated', height }); | |||
mstange
Apr 28, 2017
Contributor
How do you handle resizing the popup when the settings are expanded?
How do you handle resizing the popup when the settings are expanded?
squarewave
May 3, 2017
Author
Collaborator
The browserAction API handles that for you, which is nice :)
The browserAction API handles that for you, which is nice :)
| <em:name>Gecko Profiler</em:name> | ||
| <em:description>Collect platform profiles from Firefox Desktop.</em:description> | ||
| <em:creator>Markus Stange <mstange@themasta.com></em:creator> | ||
| <em:updateURL>https://raw.githubusercontent.com/devtools-html/Gecko-Profiler-Addon/master/gecko_profiler.update.rdf</em:updateURL> |
mstange
Apr 28, 2017
Contributor
The transition add-on shouldn't need to be updated, right? So this is just a last resort if we screwed something up. And I think it'll need to point to .../master/transition/gecko_profiler.update.rdf.
The transition add-on shouldn't need to be updated, right? So this is just a last resort if we screwed something up. And I think it'll need to point to .../master/transition/gecko_profiler.update.rdf.
| if (window.connectToGeckoProfiler) { | ||
| window.connectToGeckoProfiler({ | ||
| getProfile: () => Promise.resolve(gProfile), | ||
| getSymbolTable: (debugName, breakpadId) => getSymbolTable(debugName, breakpadId), |
mstange
Apr 28, 2017
Contributor
I think this line can be just getSymbolTable,.
I think this line can be just getSymbolTable,.
| const { resolve, reject } = symbolReplyPromiseMap.get([debugName, breakpadId].join(':')); | ||
|
|
||
| if (status === 'success') { | ||
| console.log('success ' + debugName); |
mstange
Apr 28, 2017
Contributor
let's remove this line
let's remove this line
| document.addEventListener("DOMContentLoaded", connectToPage); | ||
| } else if (event.data.type === 'ProfilerGetSymbolTableReply') { | ||
| const { debugName, breakpadId, status, result, error } = event.data; | ||
| const { resolve, reject } = symbolReplyPromiseMap.get([debugName, breakpadId].join(':')); |
mstange
Apr 28, 2017
Contributor
Should we remove the entry from the map here? Probably.
Should we remove the entry from the map here? Probably.
| @@ -0,0 +1,3 @@ | |||
| # This file was created by https://github.com/mozilla/web-ext | |||
| # Your auto-generated extension ID for addons.mozilla.org is: | |||
| geckoprofiler@mozilla.com | |||
mstange
Apr 28, 2017
Contributor
The comment sounds like a lie :)
The comment sounds like a lie :)
squarewave
Apr 28, 2017
•
Author
Collaborator
It's certainly a lie, but I'm not the one who told it, since I never touched this file. (i.e. web-ext's messages seem to be misleading.)
It's certainly a lie, but I'm not the one who told it, since I never touched this file. (i.e. web-ext's messages seem to be misleading.)
| await startProfiler(); | ||
| } else { | ||
| await stopProfiler(); | ||
| } |
mstange
Apr 28, 2017
Contributor
I'm not sure what this is trying to do. But we shouldn't change the profiler state when the add-on starts. For example, when doing startup profiling using the MOZ_PROFILER_STARTUP env variable, the profiler will already be running by the time the add-on is initialized, and we don't want to throw away the profiler buffer contents by stopping the profiler here.
I'm not sure what this is trying to do. But we shouldn't change the profiler state when the add-on starts. For example, when doing startup profiling using the MOZ_PROFILER_STARTUP env variable, the profiler will already be running by the time the add-on is initialized, and we don't want to throw away the profiler buffer contents by stopping the profiler here.
squarewave
Apr 28, 2017
Author
Collaborator
Eh, it was an attempt at making sure issue #10 is resolved, but that's a good point - I'll scrap it.
Eh, it was an attempt at making sure issue #10 is resolved, but that's a good point - I'll scrap it.
| @@ -0,0 +1,32 @@ | |||
| // NOTE: this file's only purpose is to be packaged into gecko_profiler_shim.xpi, | |||
kmaglione
May 3, 2017
Looks good to me.
Looks good to me.
|
Ehsan reminded me of something that I hadn't thought of before: We'd like to keep the ability to profile release versions of Firefox, which do not have the profiler WebExtensions API. So we can't update all installations of the old add-on to the shim add-on. |
|
I'm guessing we'll want the gecko_profiler.update.rdf to offer up the SDK based Gecko Profiler Add-on for 54 and under, and the bootstrap / replacement add-on for 55+. Any holes in that plan? |
|
Quick update on this: I've got a patch waiting for review in Bug 1337545 which fixes the shortcuts issue to allow Ctrl+Shift+1 and friends. |
- Versions of FF < 55.0 will still use the old add-on, allowing us to profile Release versions. This will however break on older versions of Nightly before the geckoProfiler API landed. - Kept the scratch HTML files used for quickly iterating on panel design. - Misc other cleanup.
|
The fix for shortcuts is r+ and just waiting to be landed, so I put the fixup commit here. Quick question, do we care about slightly out-of-date Nightly versions that still don't have the geckoProfiler API? Otherwise mikeconley's suggestion should work, which I've implemented in the latest commit. |
|
Looks good except for the minVersion thing and the xpi filenames. Let me make sure I understand what xpis we'll have in which places after this change.
I think we should change this so that:
|
| <em:description>Collect platform profiles from Firefox Desktop.</em:description> | ||
| <em:creator>Markus Stange <mstange@themasta.com></em:creator> | ||
| <em:updateURL>https://raw.githubusercontent.com/devtools-html/Gecko-Profiler-Addon/master/transition/gecko_profiler.update.rdf</em:updateURL> | ||
| <em:optionsURL>data:text/xml,<placeholder/></em:optionsURL> |
mstange
May 3, 2017
Contributor
What does this do? Is there a way to indicate "no options"?
What does this do? Is there a way to indicate "no options"?
| <em:targetApplication> | ||
| <Description> | ||
| <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id> | ||
| <em:minVersion>38.0a1</em:minVersion> |
mstange
May 3, 2017
Contributor
I think this should be 55.0a1. We don't want to allow installing the transition add-on on Firefox versions that don't support the web extension.
I think this should be 55.0a1. We don't want to allow installing the transition add-on on Firefox versions that don't support the web extension.
| { | ||
| "addons": { | ||
| "geckoprofiler@mozilla.com": [ | ||
| { "version": "0.3", "update_link": "https://raw.githubusercontent.com/devtools-html/Gecko-Profiler-Addon/master/gecko_profiler-0.3.xpi" } |
mstange
May 3, 2017
Contributor
What does this do? Is it used as a source of information when generating the update.rdf file? In any case, let's not make the version number part of the filename.
What does this do? Is it used as a source of information when generating the update.rdf file? In any case, let's not make the version number part of the filename.
|
|
||
| Cu.import("resource://gre/modules/AddonManager.jsm"); | ||
|
|
||
| const NEW_ADDON_XPI_URL = "https://raw.githubusercontent.com/devtools-html/Gecko-Profiler-Addon/master/gecko_profiler-0.1.xpi"; |
mstange
May 3, 2017
Contributor
I think we should remove the version number from the filename.
I think we should remove the version number from the filename.
I didn't know that you could offer different files to different target application versions. That's great, so I think that plan will work. |
|
@mstange, were you planning on signing the transition xpi before merging this? I wasn't intending this commit to shift everything over all in one go, but if that was your plan I can do it so long as I have that xpi. The reason I mention this is if you want the WebExtension xpi to keep the
|
|
Yes, I was planning on signing the XPIs before merging this PR. I can send the signed files to you, or I could just commit them on top of our branch. |
|
Looks good to me now! Let's merge it on Friday. |
| - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>1</kbd>: Stop / Restart profiling | ||
| - <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>2</kbd>: Capture the profile. This captures the current contents of the profiler buffer, opens a tab with perf-html at `https://perf-html.io/`, and sends the profile to it. | ||
| - <kbd>Alt</kbd>+<kbd>1</kbd>: Stop / Restart profiling | ||
| - <kbd>Alt</kbd>+<kbd>2</kbd>: Capture the profile. This captures the current contents of the profiler buffer, opens a tab with perf-html at `https://perf-html.io/`, and sends the profile to it. |
mstange
May 3, 2017
Contributor
This can be reverted again.
This can be reverted again.
Unfortunately the diff is a bit of a nightmare. Anyone interested can however look to https://github.com/squarewave/gecko-profiler-webextension for a slightly more understandable commit log.
Some highlights: