browser list used for invokeVisualizer needs be rethought
pprof invokes web browsers when the output of the command (e.g. web or weblist) needs to be visualized in a web browser.
golang/go#25853 exhibited a couple of issues around the browser invocation logic.
- the list of browsers populated in browsers needs to be rethought.
If there is BROWSER env var set, I think it should be picked as the first choice. Currently, not. FYI, go's cmd/internal/browser package has an implementation for the similar purpose.
Also, note that commands like chrome or google-chrome are not used on Mac. If they exist, they are likely not the browser command we expect.
- invokeVisualize returns once the command binary is located and can launch a process.
The command's stderr is directed to the pprof's stderr so users could be able to see the error message but only if the command outputs the error message to stderr. I don't know what's the best way to deal with it. Will it be useful if the tool prints out the exact command? Or, wait for a second, and if the process seems to exit with error code already, try again?
Thanks for opening this issue!
I think it might be helpful if the web and weblist commands communicated a little more to the user about what they did. So that if there's some weird behavior, the user can probably figure it out quickly.
I was unfamiliar with pprof and how the web command worked internally. And so typing web and seeing it break, was intimidating and confusing until 4-5 hours later.
So maybe when you type web the following will be logged:
attempting to find chrome binary
chrome binary not found.
attempting to open Firefox through firefox binary
etc etc
When chrome actually opened for me, but it didn't work, I thought there was some fundamental problem, and not that I just had the wrong binary. I was able to tell because the which chrome command gave me a suspicious path.
Maybe more robustly, if an OS had a consistent way of opening a user's default browser, then that would probably be best.
First part (changing the order of browsers) is fixed with #392.
Updatinge here #392 was rolled back to fix #402 (using "xdg-open" as the default resulted in pprof- web opening the graph in the default SVG viewer; tooltips and panning do not necessarily work when opening the graph using the default SVG viewer).
Maybe we should get rid of the svg and replace it with an html file? (embedded JS in svg is a little weird)
that way we can just use xdg-open as default