Closed Bug 1456629 Opened 2 years ago Closed 2 years ago

Create a python tool to view local gecko profiles in perf-html.io

Categories

(Testing :: Talos, defect)

Version 3
defect
Not set

Tracking

(firefox61 fixed)

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: rwood, Assigned: rwood)

References

Details

(Whiteboard: [PI:May][perf-tools])

Attachments

(1 file)

Create a stand-alone tool that will startup a local web server, share out a gecko profiles zip file, and start firefox and load the profile zip in perf-html.io.

Command line will be something like this:

python view_gecko_profile.py -b "/Users/rwood/mozilla-unified/obj-x86_64-apple-darwin17.4.0/dist/Nightly.app/Contents/MacOS/firefox" -p /Users/rwood/mozilla-unified/testing/mozharness/build/blobber_upload_dir/profile_damp.zip


This tool will be integrated with talos and raptor.
Comment on attachment 8970697 [details]
Bug 1456629 - Create a python tool to view local gecko profiles in perf-html.io;

Hi Greg,

I can't seem to get perf-html.io /from-url/ to work. I'm probably encoding the URL wrong? Also note I'm using http (but support for that is in now correct?). From my log file:

view-gecko-profile raw url is:
view-gecko-profile http://localhost:56205/profile_damp.zip
view-gecko-profile encoded url is:
view-gecko-profile http%3A%2F%2Flocalhost%3A56205%2Fprofile_damp.zip
view-gecko-profile full url is:
view-gecko-profile http://perf-html.io/from-url/http%3A%2F%2Flocalhost%3A56205%2Fprofile_damp.zip

And when perf-html.io is loaded with the above url (bottom line), perf-html.io says "Could not download the profile. TypeError: http: is not a valid URL." Webconsole says same.

Any input? I can't see what I'm doing wrong, probably missing something. You'll see in the code that I am encoding the url via urllib.quote(url, safe=''). Thanks!
Attachment #8970697 - Flags: feedback?(gtatum)
I'm getting two different errors, locally I"m getting:

> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:51769/profile_tp5o.zip. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
> TypeError: "NetworkError when attempting to fetch resource."

It looks like you need to add this header to the served ZIP file:

> Access-Control-Allow-Origin: *

I think you might be running an older cached version of the perf-html.io site, and getting an older error that should already be fixed. Could you shift-refresh to make sure?

On perf-html.io I'm getting:

> Blocked loading mixed active content “http://localhost:51769/profile_tp5o.zip"

Which is confusing to me, although perhaps it's related to the CORS issue?

The only other thing I'm noticing is the perf-html.io URL should be https, instead of http.
Thanks! Updated the code - now uses 'https://perf-html.io' instead of http, also added the "Access-Control-Allow-Origin: *" header to the file handler/server.

Unfortunately still having issues. So sorry to bug you with this :(  Now in perf-html.io I get "Could not download the profile. TypeError: NetworkError when attempting to fetch resource". Webconsole shows:

TypeError: "NetworkError when attempting to fetch resource."
Vn    https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:5:1232
Zn    https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:14:407
r     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:251066
se    https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:120954
componentDidMount    https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:28:42108
commitLifeCycles     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:69681
t     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:56181
x     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:61628
_     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:61329
m     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:60461
h     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:59865
updateContainer     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:72472
o     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:93240
unbatchedUpdates     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:70966
o     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:93209
render     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:40:94162
<anonymous>     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:28:44745
n     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:105
<anonymous>     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:105877
n     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:105
<anonymous>     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:452
<anonymous>     https://perf-html.io/a0bb41a636a38ac423ba.bundle.js:1:2 Root.js:192:10
Flags: needinfo?(gtatum)
Update: it totally works fine with Google Chrome, i.e.:

python view_gecko_profile.py -b "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" -p /Users/rwood/mozilla-unified/testing/mozharness/build/blobber_upload_dir/profile_damp.zip

Starts up Chrome and the gecko profile zip opens successfully in perf-html.io.

In Firefox I did a forced refresh... don't really understand why it doesn't work there.
Hey :jgraham, just found 'wptserve' and it's awesome thanks! Question - am I applying the "Access-Control-Allow-Origin: *" header correctly on my file handler?

In the docroot, the code first writes out a '__dir__.headers' file with only one line: Access-Control-Allow-Origin: *
Flags: needinfo?(james)
So, I would do two things differently:

1. Depend on the in-tree wptserve. We have not always been great making releases, so that's more up to date. It's in testing/web-platform/tests/tools/wptserve

2. Intead of writing a .headers file, subclass the FileHandler, something like

class HeadersFileHandler(FileHandler):
    def __init__(self, base_path=None, url_base=None, headers=None):
        super(HeadersFileHandler, self).__init__(base_path, url_base)
        self.headers = headers

    def __call__(self, request, response):
        super(HeadersFileHandler, self).__call__(request, response)
        if self.headers:
            response.headers.update(self.headers)
        return response
Flags: needinfo?(james)
Argh, I'm not sure of a way around this. It looks like anything being run through `fetch()` is being tagged as active content on perf-html, which is not allowed to be fetched over http. It looks like Chrome has an exception that allows content to be loaded over localhost. I confirmed Chrome's behavior by fetching over localhost through a faked domain name, and it failed with the same mixed content error.

I spent some time thinking about it, and I can't figure out a way around it, other than to change Firefox's rules about 127.0.0.1 to match Chrome's. I'll talk to a few folks and see if there is any path forward here :-/
Flags: needinfo?(gtatum)
Whiteboard: [PI:May][perf-tools]
(In reply to Greg Tatum [:gregtatum] [@gregtatum] from comment #10)

Thanks Greg!
Success! It looks like mixed content is allowed on http://127.0.0.1/ but not http://localhost/ on Firefox. So changing the address to the IP address makes it work on my machine.

This change was implemented in Bug 903966
(In reply to Greg Tatum [:gregtatum] [@gregtatum] from comment #12)
> Success! It looks like mixed content is allowed on http://127.0.0.1/ but not
> http://localhost/ on Firefox. So changing the address to the IP address
> makes it work on my machine.
> 
> This change was implemented in Bug 903966

EXCELLENT made the change and works for me too in Firefox (and Chrome). Thanks Greg!! :)
Comment on attachment 8970697 [details]
Bug 1456629 - Create a python tool to view local gecko profiles in perf-html.io;

https://reviewboard.mozilla.org/r/239436/#review247044

this looks good, I think a future improvement (file a bug?) would be to create:
./mach talos-profile <path to .zip file>

and that would automatically find the firefox binary- ideally it could bring up a list of profiles generated and stored in a standard way from the ./mach talos-test ..., command
Attachment #8970697 - Flags: review?(jmaher) → review+
Blocks: 1458597
(In reply to Joel Maher ( :jmaher ) (UTC-4) from comment #15)

Thank you, and great idea re:mach integration, I filed Bug 1458597
hg error in cmd: hg rebase -s dbb33c11cc39916e5698b8dc2a3f11269e3bf14b -d 5ea81be0d028: abort: can't rebase public changeset dbb33c11cc39
(see 'hg help phases' for details)
Pushed by rwood@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/1d86574e9bfd
Create a python tool to view local gecko profiles in perf-html.io; r=jmaher
https://hg.mozilla.org/mozilla-central/rev/1d86574e9bfd
Status: ASSIGNED → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.