Skip to content
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

Headless? #65

Closed
jonmmease opened this issue Apr 7, 2018 · 19 comments
Closed

Headless? #65

jonmmease opened this issue Apr 7, 2018 · 19 comments

Comments

@jonmmease
Copy link
Contributor

I built the project on OS X and ran the following png export command

~> bin/plotly-graph-exporter.js '{"data":[{"y": [3, 2, 5, 3]}],"layout":{}}' -o out.png

The out.png image is generated successfully, but I noticed that the electron window pops up in front of my other windows.

Is there any way to prevent the popup? I'm concerned this would be a bit disruptive for eventual python/R users.

cross reference: #21, plotly/plotly.py#880
cc: @cpsievert @etpinard @jackparmer

@jackparmer
Copy link
Contributor

@n-riesco @JamesCropcho @etpinard Any thoughts here? Do we need #63 to prevent the popup?

@n-riesco
Copy link
Contributor

n-riesco commented Apr 8, 2018

I guess that adding show: false here and here could do the trick, but I haven't tested it.

@JamesCropcho
Copy link
Contributor

@jackparmer I don't believe I'll win any popularity contests with my thoughts here, but I'll share them as you have requested.

I do not believe that a window popping up for half a second (or even many such windows) in an application targeting computer-savvy types (e.g. Plotly users) is substantially "disruptive" to warrant significant effort from Plotly to remedy it.

@jackparmer
Copy link
Contributor

jackparmer commented Apr 8, 2018 via email

@JamesCropcho
Copy link
Contributor

@jackparmer Ah, okay. That is a different use-case than @jmmease described.

I don't have any experience with this particular issue.

I guess that adding show: false here and here could do the trick, but I haven't tested it.

@n-riesco's suggestion above sounds like as a good an initial experiment/step, as any. More broadly, an experimental approach is probably needed, i.e. trying various ideas which seem promising and seeing what works.

@JamesCropcho
Copy link
Contributor

Do we need #63 to prevent the popup?

@jackparmer As the author of #63, I am pretty sure that #63 would neither fix this, nor exacerbate it.

@etpinard
Copy link
Contributor

etpinard commented Apr 9, 2018

This issue is essentially a duplicate of #22

This repo won't attempt to do anything fancy (e.g. xvfb) to wrap electron in a headless executable. We'll just wait until electron supports chromium's --headless flag natively.

@jonmmease
Copy link
Contributor Author

I just tried out @n-riesco suggestion and added show: false to the _browserWindowOpts in src/app/runner/coerce-opts.js and that did the trick (the window no longer pops up when running plotly-graph-exporter.js).

Would this be a reasonable command line option eventually?

@etpinard
Copy link
Contributor

etpinard commented Apr 9, 2018

What does show: false do exactly? Does it still create a window and simply doesn't focus on it on creation?

@jackparmer
Copy link
Contributor

jackparmer commented Apr 9, 2018

Would this be a reasonable command line option eventually?

Definitely. The longterm vision was to package this with plotly.py so we stop getting complaints like this: plotly/plotly.py#880 (comment)

@jonmmease
Copy link
Contributor Author

Interesting, it seems that the show: false option suppresses the window for a png export

bin/plotly-graph-exporter.js '{"data":[{"y": [3, 2, 5, 3]}],"layout":{}}' -o out --format png

But when I do pdf export

bin/plotly-graph-exporter.js '{"data":[{"y": [3, 2, 5, 3]}],"layout":{}}' -o out --format pdf

There are actually two popup windows, and only the first one is hidden by the show option

@etpinard
Copy link
Contributor

etpinard commented Apr 9, 2018

@n-riesco
Copy link
Contributor

n-riesco commented Apr 9, 2018

@etpinard The options are documented here

@etpinard
Copy link
Contributor

etpinard commented Apr 9, 2018

Yep, I saw that page, but

image

isn't very clear. I guess I could try it out myself. Sorry for being lazy.

@jonmmease
Copy link
Contributor Author

@etpinard Awesome, adding show: false to image-exporter/src/component/plotly-graph/render.js took care of the second window too.

@JamesCropcho
Copy link
Contributor

Well, initial experimentation makes it sound easy enough…

If someone else is assigned this or has stepped up, by all means I am fine with someone else spearheading this. Or if not, upon request I can draft a pull request with these show parameters.

@jackparmer
Copy link
Contributor

@JamesCropcho - Please go ahead and make a PR for this. Afterwards we can merge #63 and put out the first release! 🍾

@JamesCropcho
Copy link
Contributor

@jmmease Are you able to see #66? If so, is it identical to the changes you made, which worked as desired?

etpinard pushed a commit that referenced this issue Apr 16, 2018
* #65 (comment)

* "Probably best to set show: opts.debug for debugging purposes."

* "shall we add show: false to the server too?"

* "there's a few more createBrowserWindow calls" "Moreover, here too we should set show: opts.debug."

* `remote.createBrowserWindow`'s `show` parameter appears to treat `undefined` as true. This commit performs like casting to a Boolean.

* "On Windows and Linux, setting this to true should keep the electron window from displaying in the taskbar, which I believe to be desirable for making image export a seamless experience for Windows and Linux Python/R users. I think this change would just involve adding the skipTaskbar option everywhere the show option is added."

* "To hide the electron icon from the dock on OS X it is recommended (electron-userland/electron-builder#1456) to add "extendInfo": {"LSUIElement": 1} to the top-level mac configuration settings"

* Manual reverting of changes in package.json from previous commits on `forbid-popup-windows`
@etpinard
Copy link
Contributor

Closed via #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants