Repository: pyvista/pyvista

Issue #3979: Trame widget timeout issues on remote server
Created: 2023-02-08T11:22:23Z
Describe the bug, what's wrong, and what you expected.
So I'm trying to run the compute normals example on a headless display. I run Jupyter with jupyter lab --no-browser --port=1234 on the host machine then connect with nohup ssh -NL localhost:1234:localhost:1234 HOSTMACHINE@IP. Before the addition of trame Pyvista did not work with any 3D rendering with this setup (host machine doesn't have xvfb), but I thought to try it out now with the new backend. I can now run the other examples such as clipping with a surface or surface reconstruction with a 3D interface (yay!), but both examples in the compute normals page result in the connection being terminated. This error occurs before doing the mesh.compute_normals command in the example, but just when plotting the base example mesh. The error also occurs when running the nefertiti example on the same page, so I'm not sure if its an issue with these particular examples or something more sinister. The pyvista window alternates between a blank page (with only the options bar for moving the 3d interface around) to the "connection closed" as shown in the screenshot, alternating after ~1 second. It then repeats the error message below of

WARNING:aiohttp.websocket:Client protocols [''] don’t overlap server-known ones ()
ERROR:root:Exception raised
ERROR:root:ConnectionResetError(104, 'Connection reset by peer')
ERROR:root:Traceback (most recent call last):
File "/home/dm575/miniconda3/lib/python3.9/site-packages/wslink/backends/aiohttp/init.py", line 501, in onMessage
await self.sendWrappedMessage(
File "/home/dm575/miniconda3/lib/python3.9/site-packages/wslink/backends/aiohttp/init.py", line 638, in sendWrappedMessage
await ws.send_bytes(attachments[key])
File "/home/dm575/miniconda3/lib/python3.9/site-packages/aiohttp/web_ws.py", line 315, in send_bytes
await self._writer.send(data, binary=True, compress=compress)
File "/home/dm575/miniconda3/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 688, in send
await self._send_frame(message, WSMsgType.BINARY, compress)
File "/home/dm575/miniconda3/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 659, in _send_frame
await self.protocol._drain_helper()
File "/home/dm575/miniconda3/lib/python3.9/site-packages/aiohttp/base_protocol.py", line 87, in _drain_helper
await asyncio.shield(waiter)
File "/home/dm575/miniconda3/lib/python3.9/asyncio/futures.py", line 284, in await
yield self  # This tells Task to wait for completion.
File "/home/dm575/miniconda3/lib/python3.9/asyncio/tasks.py", line 328, in __wakeup
future.result()
File "/home/dm575/miniconda3/lib/python3.9/asyncio/futures.py", line 201, in result
raise self._exception
File "/home/dm575/miniconda3/lib/python3.9/asyncio/selector_events.py", line 941, in _write_ready
n = self._sock.send(self._buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

TIA for any help!
Steps to reproduce the bug.
import pyvista as pv
import numpy as np
from pyvista import examples

pv.global_theme.trame.server_proxy_enabled = True
pv.set_jupyter_backend("client")

mesh = examples.download_topo_global()
mesh.plot(cmap="gist_earth", show_scalar_bar=False, notebook=True)

System Information
--------------------------------------------------------------------------------
  Date: Wed Feb 08 11:07:34 2023 GMT

                  OS : Linux
              CPU(s) : 72
             Machine : x86_64
        Architecture : 64bit
                 RAM : 157.3 GiB
         Environment : Jupyter
         File system : ext4
         GPU Details : error

  Python 3.9.15 | packaged by conda-forge | (main, Nov 22 2022, 15:55:03)
  [GCC 10.4.0]

             pyvista : 0.38.1
                 vtk : 9.2.5
               numpy : 1.24.2
             imageio : 2.25.0
              scooby : 0.7.1
               pooch : v1.6.0
          matplotlib : 3.6.3
               PyQt5 : 5.15.7
             IPython : 8.9.0
          ipyvtklink : 0.2.2
               scipy : 1.7.1
                tqdm : 4.64.1
              meshio : 5.3.4
          jupyterlab : 3.4.4
           pythreejs : 2.3.0
               trame : 2.2.6
        trame_client : 2.5.1
        trame_server : 2.8.1
           trame_vtk : 2.0.17
jupyter_server_proxy : 3.2.2
--------------------------------------------------------------------------------
Screenshots

cc @dennissergeev who is also interested in this!

Duplicate issue #4708: Trame app crashes with large meshes
Created: 2023-07-26T16:01:00Z
Describe the bug, what's wrong, and what you expected.
Hi,
I was trying to display a large mesh with the new trame backend (~5M vertices) in a jupyter notebook, but the app crashes with this error.
ERROR:root:Exception raised
ERROR:root:ConnectionResetError(104, 'Connection reset by peer')
ERROR:root:Traceback (most recent call last):
  File "/home/container_user/.local/lib/python3.10/site-packages/wslink/protocol.py", line 329, in onMessage
    await self.sendWrappedMessage(
  File "/home/container_user/.local/lib/python3.10/site-packages/wslink/protocol.py", line 466, in sendWrappedMessage
    await ws.send_bytes(attachments[key])
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/web_ws.py", line 315, in send_bytes
    await self._writer.send(data, binary=True, compress=compress)
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/http_websocket.py", line 688, in send
    await self._send_frame(message, WSMsgType.BINARY, compress)
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/http_websocket.py", line 659, in _send_frame
    await self.protocol._drain_helper()
  File "/usr/local/lib/python3.10/dist-packages/aiohttp/base_protocol.py", line 90, in _drain_helper
    await asyncio.shield(waiter)
  File "/usr/lib/python3.10/asyncio/futures.py", line 285, in __await__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup
    future.result()
  File "/usr/lib/python3.10/asyncio/futures.py", line 201, in result
    raise self._exception.with_traceback(self._exception_tb)
  File "/usr/lib/python3.10/asyncio/selector_events.py", line 949, in _write_ready
    n = self._sock.send(self._buffer)
ConnectionResetError: [Errno 104] Connection reset by peer

However it works well with pythreejs.
I even have the issue with 1.5M vertices
Steps to reproduce the bug.
Call the plot function on a pyvista object having around 5 millions vertices.
System Information
--------------------------------------------------------------------------------
  Date: Wed Jul 26 15:56:10 2023 Europe

                  OS : Linux
              CPU(s) : 8
             Machine : x86_64
        Architecture : 64bit
                 RAM : 54.9 GiB
         Environment : Python
          GPU Vendor : Mesa/X.org
        GPU Renderer : llvmpipe (LLVM 12.0.0, 256 bits)
         GPU Version : 4.5 (Core Profile) Mesa 21.2.6
    MathText Support : False

  Python 3.10.12 (main, Jun  7 2023, 12:45:35) [GCC 9.4.0]

             pyvista : 0.40.0
                 vtk : 9.2.6
               numpy : 1.23.5
          matplotlib : 3.7.1
              scooby : 0.7.2
               pooch : v1.7.0
             imageio : 2.27.0
             IPython : 7.16.1
            colorcet : 3.0.1
             cmocean : v3.0.3
          ipyvtklink : 0.2.2
          ipywidgets : 7.6.3
               scipy : 1.11.0
                tqdm : 4.65.0
              meshio : 5.3.4
          jupyterlab : 4.0.3
           pythreejs : 2.4.2
               trame : 2.5.0
        trame_client : 2.9.4
        trame_server : 2.11.5
           trame_vtk : 2.5.4
jupyter_server_proxy : 4.0.0
        nest_asyncio : 1.5.6
--------------------------------------------------------------------------------
Screenshots

Closing comment (2023-10-02T00:15:18Z): This looks like a duplicate of #3979 and #4652 which is due to connection timeouts during the transfer of the large data through jupyter-server-proxy. Please keep an eye on #5001 and #4652 as we'll soon transition away from using jupyter-server-proxy to the Jupyter comms directly which should solve this.