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

--no-sandbox flag missing on Windows #26

Closed
genneth opened this issue Jul 27, 2020 · 11 comments · Fixed by #29
Closed

--no-sandbox flag missing on Windows #26

genneth opened this issue Jul 27, 2020 · 11 comments · Fixed by #29
Labels
bug something broken
Milestone

Comments

@genneth
Copy link

genneth commented Jul 27, 2020

Plotly 4.9, kaleido-0.0.2, on windows, from inside a jupyter notebook. Trying to use show(renderer='svg') gives a modal dialog box with error.

@jonmmease
Copy link
Collaborator

Hi @genneth, thanks for the report. Here are a few questions.

Could you share a screenshot of the dialog?

Do you get the same error with png format with show(renderer='png')?

Is there a Python exception displayed in the notebook as well? If so could you include that text.

After the error occurs, can you execute the following to see if there is any more information:

import plotly.io
print(plotly.io.kaleido.scope._std_error.getvalue())

Thanks!

@genneth
Copy link
Author

genneth commented Jul 28, 2020

image

The dialog box reappears 3 or 4 times, and after that the ipython kernel seems to stop responding, so cannot run the diagnostic :-( No diagnostic output in the terminal where the jupyter session is started.

Same happens with png renderer.

@jonmmease
Copy link
Collaborator

Thanks for the extra info @genneth,

Here's one more thing I'd like you to try to see if we can get any more information on what went wrong.

First, run this python snippet from your same python environment. This will print out the path to the kaleido executable.

import os
import kaleido
print(os.path.join(os.path.dirname(kaleido.__file__), "executable", "kaleido"))
C:\path\to\site-packages\kaleido\executable\kaleido

Then from a plain windows CMD prompt, run this command (with your own path that was displayed above)

> "C:\path\to\site-packages\kaleido\executable\kaleido" plotly

If successful, this will display something this, and the process will not exit:

[0728/055837.997:ERROR:registration_protocol_win.cc(131)] TransactNamedPipe: The pipe has been ended. (0x6D)
[0728/055838.005:WARNING:resource_bundle.cc(435)] locale_file_path.empty() for locale
{"code": 0, "message": "Success", "result": null, "version": "0.0.1"}
[0728/055838.095:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)

If this works for you, then while the process is still running copy and paste this string into the console and press enter.

{"data":{"layout":{}}}

If successful, this would print out a large base64 encoded string.

I'm assuming one of these is going to crash for you, and if it does can you please include anything that is printed out in the command prompt.

Thanks!

@jonmmease
Copy link
Collaborator

One other thing to confirm. Are you able to successfully run the full Chrome or Chromium web browser on this same system?

@genneth
Copy link
Author

genneth commented Jul 28, 2020

Running kaleido plotly in CMD gives:

[0728/124146.422:ERROR:registration_protocol_win.cc(131)] TransactNamedPipe: The pipe has been ended. (0x6D)
[0728/124146.492:WARNING:resource_bundle.cc(435)] locale_file_path.empty() for locale
{"code": 0, "message": "Success", "result": null, "version": "0.0.2"}
[0728/124149.843:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)
[0728/124154.365:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 1 time(s)
[0728/124157.068:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 2 time(s)
[0728/124159.244:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 3 time(s)
[0728/124201.364:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 4 time(s)
[0728/124203.766:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 5 time(s)
[0728/124206.044:WARNING:gpu_process_host.cc(1217)] The GPU process has crashed 6 time(s)
[0728/124206.046:ERROR:browser_gpu_channel_host_factory.cc(153)] Failed to launch GPU process.

With previous error dialogbox before printing each "GPU process has crashed" line. I am able to run normal full Chrome on the same system (help/about says: Version 83.0.4103.116 (Official Build) (64-bit))

After the above lines, the kaleido process seems to freeze and no further input is possible in CMD. (This then led me to realise that I had a few copies of kaleido hanging around... killed them from taskmgr.)

@jonmmease
Copy link
Collaborator

Hi @genneth, thanks. It's at least helpful to see that something is going wrong with the GPU initialization.

I just checked and realized that, for windows, we're not passing the --no-sandbox flag (https://github.com/plotly/Kaleido/blob/master/repos/win_scripts/kaleido.cmd) the way we are for linux (https://github.com/plotly/Kaleido/blob/master/repos/linux_scripts/launch_script). Can you try this:

> "C:\path\to\site-packages\kaleido\executable\kaleido" plotly --no-sandbox

Then, the next thing I'd want to try is disabling GPU acceleration with the --disable-gpu flag

> "C:\path\to\site-packages\kaleido\executable\kaleido" plotly --no-sandbox --disable-gpu 

There are a bunch of chromium --disable-gpu-* flags that we could try if that doesn't work (Full list at https://peter.sh/experiments/chromium-command-line-switches/). But to be honest I'd be mostly guessing at that point.

Thanks for sticking with this 😃

@genneth
Copy link
Author

genneth commented Jul 28, 2020

--no-sandbox kind of worked?

[0728/144712.299:ERROR:registration_protocol_win.cc(131)] TransactNamedPipe: The pipe has been ended. (0x6D)
[0728/144712.319:WARNING:resource_bundle.cc(435)] locale_file_path.empty() for locale
{"code": 0, "message": "Success", "result": null, "version": "0.0.2"}
[0728/144714.065:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)
[0728/144715.688:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)
[0728/144717.237:ERROR:registration_protocol_win.cc(103)] CreateFile: The system cannot find the file specified. (0x2)
{"data":{"layout":{}}}
{"code": 1, "message": "Failed to serialize document: Uncaught", "result": null, "version": "0.0.2"}
^CTerminate batch job (Y/N)? y

Didn't hang, accepted the {"data":{"layout":{}}} input though apparently didn't like it. Looks like a plausible winner. Is there a way to have the plotly integration pass that flag?

@jonmmease
Copy link
Collaborator

jonmmease commented Jul 28, 2020

Yeah, it got further!

The {"code": 1, "message": "Failed to serialize document: Uncaught", "result": null, "version": "0.0.2"} still indicates that something went wrong. It should print out a JSON line with "code": 0 and a long base64 encoded string as the "result" key. This error indicates an error in the JavaScript portion of the Plotly scope. This could happen in an offline environment, or behind a proxy that blocks the default plotly.js CDN. When calling Kaleido through plotly.py this isn't an issue because plotly.py points Kaleido to it's own bundled copy of plotly.js

There isn't currently a way to add extra args through Python, but for testing you can add them manually to the C:\path\to\site-packages\kaleido\executable\kaleido.cmd script:

It should currently look like:

@echo off
setlocal
chdir /d "%~dp0"
.\bin\kaleido.exe %*

You can add chome flags before the %* wildcard. For example

@echo off
setlocal
chdir /d "%~dp0"
.\bin\kaleido.exe --no-sandbox %*

We'll definitely add this flag in the next release.

@genneth
Copy link
Author

genneth commented Jul 28, 2020

I am indeed behind proxy that blocks the default plotly.js CDN. I can confirm that changing kaleido.cmd as above causes my original problem to disappear, and everything appears to work as intended.

@jonmmease
Copy link
Collaborator

Awesome, that's great news! Thanks again for the report and helping us get to the bottom of this one.

@jonmmease jonmmease changed the title kaleido.exe unable to start corretly 0xc0000022 --no-sandbox flag missing on Windows Jul 28, 2020
@jonmmease jonmmease added the bug something broken label Jul 28, 2020
@jonmmease jonmmease added this to the 0.1.0 milestone Jul 28, 2020
@jonmmease jonmmease modified the milestones: 0.1.0, 0.0.3 Jul 28, 2020
@jonmmease
Copy link
Collaborator

This fix has been released in version 0.0.3

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

Successfully merging a pull request may close this issue.

2 participants