-
Notifications
You must be signed in to change notification settings - Fork 421
Allow addons to inject profiles directly into the profiler via the postMessage API #4835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
For fun, here is a 10 hour profile. https://share.firefox.dev/3R1NC1S |
4a5d76e
to
98c05cf
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #4835 +/- ##
=======================================
Coverage 88.38% 88.39%
=======================================
Files 301 301
Lines 26876 26910 +34
Branches 7268 7286 +18
=======================================
+ Hits 23754 23786 +32
- Misses 2906 2908 +2
Partials 216 216 ☔ View full report in Codecov by Sentry. |
This is great! I've wanted a way to postMessage profiles into the profiler for a different reason: To make samply work on macOS when Safari is the default browser. Safari doesn't allow network requests from the profiler to localhost (because the profiler is https and localhost is http), so a potential workaround would be to open a localhost page with a button which opens the profiler in a new tab and postMessages the profile into it. The only trouble is the question when to call postMessage - the localhost page can't know when the profiler page is done loading. Oh, and the profiler wouldn't have a way to request symbols. (I suppose the localhost page could send a message channel along with the initial postMessage, as a way to initiate bidirectional communication...) |
I added a way to poll the page for when it's ready. In an addon it seems like you can just wait a tick and it'll be ready. |
The codecoverage failure is a false positive as far as I can tell, since most of them are assertions for states that shouldn't happen. |
515fdff
to
6e245dc
Compare
I force pushed a new version of the code that removes the mentions of an addon, as this works with a plain webpage (barring any unforeseen CSP issues). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this looks interesting!
I left a few comments, tell me what you think!
Especially I don't see if/why the change to the action PROFILE_LOADED
adding a dataSource
property is needed.
r=me with the comments added and the changes to the PROFILE_LOADED action removed (unless we discussed otherwise).
7c6e3fc
to
930d041
Compare
@@ -82,6 +82,7 @@ class ProfileLoaderImpl extends PureComponent<Props> { | |||
case 'unpublished': | |||
case 'none': | |||
// nothing to do | |||
/* istanbul ignore next */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, is that one or 2 lines too high? :-)
I'm prototyping an addon to visualize Firefox Translations taskcluster runs, but I need a way to inject my profiles directly into the profiler UI.
My code is still a prototype that I got working locally:
https://github.com/gregtatum/taskcluster-webext
Here is an example injection:
https://github.com/gregtatum/taskcluster-tools/blob/main/extension/profiler_content.js
This is an example profile:
https://share.firefox.dev/3GOQafr