plotly / plotly/Kaleido

Kaleido crashes when rendering a plot to an image using Plotly's `to_image()` method using Alpine Linux

Open
#239 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
498
Forks
62
Avg merge
1d 11h
Merged PRs (30d)
2

Description

Description:
I am using Kaleido to render Plotly plots as images via the to_image() method in an Alpine-based Docker environment. The process fails when Kaleido attempts to open Chromium, resulting in a GPU process crash. The error details and debug logs are provided below.

I’ve been trying to find a solution for this issue for a very long time now, and I’ve explored almost every possible approach, but Alpine Linux seems to be incompatible with Kaleido.

This issue has a substantial impact on our product and, I assume, on many other Plotly and Kaleido users facing similar constraints.

We would deeply appreciate it if you could prioritize this issue and allocate resources to apply a fix as soon as possible. The resolution of this problem is critical for our company, and we are willing to support the effort.

Steps to Reproduce:

  1. Build a Docker image using Alpine Linux.
  2. Install Kaleido and Plotly.
  3. Run plotly.graph_objects with to_image() to generate an image.
  4. Observe the error related to GPU process failure.

Expected Behavior:
Kaleido should render the Plotly plot to an image without crashing.

Actual Behavior:
Kaleido fails to launch the GPU process and crashes, as shown in the error traceback.

Error Traceback:

Full traceback (with KALEIDO_DEBUG enabled) is attached at the end of the issue

[1229/134817.090956:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.090956:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 1 time(s)
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[1229/134817.705795:FATAL:gpu_data_manager_impl_private.cc(423)] GPU process isn't usable. Goodbye.

Additional Information:

  • Chromium Path: /usr/bin/chromium
  • Python Version: 3.11
  • Plotly Version: 5.24.1
  • Kaleido Version: 1.0.0rc0 (0.2.1 version does not works for Alpine Linux)
  • Kaleido Debug Logs: The debug logs indicate that Kaleido is trying to launch the Chromium browser but fails due to GPU process issues:
**Displaying generated HTML***
<!DOCTYPE html>
<html>
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.KaleidoReport = ["start"];
function logError(e) {
window.KaleidoReport.push("error");
window.KaleidoReport.push(e);
if (!navigator.onLine) {
window.KaleidoReport.push("offline");
}
}
</script>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script src="https://cdn.plot.ly/plotly-2.35.2.min.js" charset="utf-8" onerror="logError('plotly')"></script>
<script type="text/javascript" id="MathJax-script" src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/mathjax/MathJax.js?config=TeX-AMS-MML_SVG" onerror="logError('mathjax')"></script>
<script src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/kaleido_scopes.js" onerror="logError('scoper')"></script>  </head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
***end****
**Displaying generated HTML***
<!DOCTYPE html>
<html>
<head>
<style id="head-style"></style>
<title>Kaleido-fier</title>
<script>
window.KaleidoReport = ["start"];
function logError(e) {
window.KaleidoReport.push("error");
window.KaleidoReport.push(e);
if (!navigator.onLine) {
window.KaleidoReport.push("offline");
}
}
</script>
<script>
window.PlotlyConfig = {MathJaxConfig: 'local'}
</script>
<script src="file:///usr/local/lib/python3.11/site-packages/plotly/package_data/plotly.min.js" charset="utf-8" onerror="logError('plotly')"></script>
<script type="text/javascript" id="MathJax-script" src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/mathjax/MathJax.js?config=TeX-AMS-MML_SVG" onerror="logError('mathjax')"></script>
<script src="file:///usr/local/lib/python3.11/site-packages/kaleido/vendor/kaleido_scopes.js" onerror="logError('scoper')"></script>  </head>
<body style="{margin: 0; padding: 0;}"><img id="kaleido-image"><img></body>
</html>
***end****
No loop, no thread
STDERR: <_io.TextIOWrapper name='<stderr>' mode='w' encoding='utf-8'>
TEMP DIR NAME: /tmp/tmpm8s2vf_a
DEBUG REPORT:
BROWSER_PATH: /usr/bin/chromium
USER_DATA_DIR: /tmp/tmpm8s2vf_a
read_jsons (blocking):
write_json:Starting watchdog

write_json: {"id": 0, "method": "Target.getTargets"}
wrote_json.
Old Headless mode will be removed from the Chrome binary soon. Please use the new Headless mode (https://developer.chrome.com/docs/chromium/new-headless) or the chrome-headless-shell which is a standalone implementation of the old Headless mode (https://developer.chrome.com/blog/chrome-headless-shell).

qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
[1229/134816.424079:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134816.472629:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134816.475996:ERROR:bus.cc(407)] Failed to connect to the bus: Failed to connect to socket /var/run/dbus/system_bus_socket: No such file or directory
[1229/134817.080670:WARNING:bluez_dbus_manager.cc(234)] Floss manager service not available, cannot set Floss enable/disable.
[1229/134817.090198:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.090956:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 1 time(s)
{"id":0,"result":{"targetInfos":[]}}
[1229/134817.200035:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.200133:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 2 time(s)
read_jsons: {'id': 0, 'result': {'targetInfos': []}}
run_read_loop() found future for key ('', 0)
read_jsons (blocking):
Creating tab w/ file: file:///root/.kaleido-s36n1r02/index.html
write_json:
[1229/134817.228431:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.228537:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 3 time(s)
write_json: {"id": 1, "method": "Target.createTarget", "params": {"url": "file:///root/.kaleido-s36n1r02/index.html"}}
wrote_json.
{"id":1,"result":{"targetId":"8A944A2E7E2C38FFA32651B3B76FC251"}}
[1229/134817.572600:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.574345:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 4 time(s)
read_jsons: {'id': 1, 'result': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251'}}
run_read_loop() found future for key ('', 1)
write_json:
write_json: {"id": 2, "method": "Target.attachToTarget", "params": {"targetId": "8A944A2E7E2C38FFA32651B3B76FC251", "flatten": true}}
wrote_json.
read_jsons (blocking):
[1229/134817.649732:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.649846:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 5 time(s)
{"method":"Target.attachedToTarget","params":{"sessionId":"82ABBD20EBBEDF8A0A4CF0BF552E0648","targetInfo":{"targetId":"8A944A2E7E2C38FFA32651B3B76FC251","type":"page","title":"","url":"file:///root/.kaleido-s36n1r02/index.html","attached":true,"canAccessOpener":false,"browserContextId":"DA133DEF98442C73694452C71FBB83AB"},"waitingForDebugger":false}}
read_jsons: {'method': 'Target.attachedToTarget', 'params': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648', 'targetInfo': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251', 'type': 'page', 'title': '', 'url': 'file:///root/.kaleido-s36n1r02/index.html', 'attached': True, 'canAccessOpener': False, 'browserContextId': 'DA133DEF98442C73694452C71FBB83AB'}, 'waitingForDebugger': False}}
Checking subscription key: * against event method Target.attachedToTarget
All subscription: {'method': 'Target.attachedToTarget', 'params': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648', 'targetInfo': {'targetId': '8A944A2E7E2C38FFA32651B3B76FC251', 'type': 'page', 'title': '', 'url': 'file:///root/.kaleido-s36n1r02/index.html', 'attached': True, 'canAccessOpener': False, 'browserContextId': 'DA133DEF98442C73694452C71FBB83AB'}, 'waitingForDebugger': False}}
read_jsons (blocking):
{"id":2,"result":{"sessionId":"82ABBD20EBBEDF8A0A4CF0BF552E0648"}}
read_jsons: {'id': 2, 'result': {'sessionId': '82ABBD20EBBEDF8A0A4CF0BF552E0648'}}
run_read_loop() found future for key ('', 2)
Activating page
write_json:
write_json: {"id": 0, "method": "Page.bringToFront", "sessionId": "82ABBD20EBBEDF8A0A4CF0BF552E0648"}
wrote_json.
read_jsons (blocking):
[1229/134817.705593:ERROR:gpu_process_host.cc(976)] GPU process launch failed: error_code=1002
[1229/134817.705708:WARNING:gpu_process_host.cc(1416)] The GPU process has crashed 6 time(s)
[1229/134817.705795:FATAL:gpu_data_manager_impl_private.cc(423)] GPU process isn't usable. Goodbye.
qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
Browser is being closed because chrom* closed
is_closed called with wait: 0
Browser was already closed.
caught OSError in read() [Errno 9] Bad file descriptor
Tempfile still exists?: False
Exception in callback Browser.run_read_loop.<locals>.check_error(<Task cancell...owser.py:671>>) at /usr/local/lib/python3.11/site-packages/choreographer/browser.py:663
handle: <Handle Browser.run_read_loop.<locals>.check_error(<Task cancell...owser.py:671>>) at /usr/local/lib/python3.11/site-packages/choreographer/browser.py:663>
Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/kaleido/**init**.py", line 65, in to_image
res = await tab.send_command("Page.bringToFront")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
choreographer.browser.BrowserClosedError: Command not completed because browser closed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.11/asyncio/events.py", line 84, in _run
self._context.run(self._callback, *self._args)
File "/usr/local/lib/python3.11/site-packages/choreographer/browser.py", line 664, in check_error
e = result.exception()
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/choreographer/browser.py", line 673, in read_loop
responses = await self.loop.run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
asyncio.exceptions.CancelledError
Error while generating bar chart. Command not completed because browser closed.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the reported to_image() failure in the Alpine Docker environment with Python 3.11, Kaleido 1.0.0rc0, and Chromium at /usr/bin/chromium. Inspect the browser launch and GPU-process failure, then verify completion by rendering a Plotly image without the browser closing or raising BrowserClosedError.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, linux, python
Domain
backend, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
32/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.