Python rendering crashes if pyvista previously used
If a user's python program explicitly invokes pyvista
plotting, then subsequent calling of gmsh.fltk.run()
to render a scene or mesh will crash with error:
File "gmsh.py", line 9825, in run
lib.gmshFltkRun(
OSError: exception: access violation reading 0x00000000000000B4
Here is a simple minimum working example:
import pyvista
import gmsh
# draw something in pyvista
pt = pyvista.Plotter()
pt.add_mesh(pyvista.Cylinder())
pt.show()
# create gmsh scene
gmsh.initialize()
gmsh.model.occ.add_point(0,0,0)
# attempt to view; crashes
gmsh.fltk.run()
This code runs fine if pt.show()
is excluded, but nothing else is changed (i.e. pyvista.Plotter()
is still called).
This error occurs for me on Windows 11, Python 3.8.13, PyVista 0.37.0 (latest), and python gmsh 4.11.0. I suspect it may be caused by gmsh using pyvista (or related sub-library) and attempting to reinitialise something already initialised, but I can't find the relevant code in this repo.
In my application, it is necessary to use pyvista directly for plotting 3D geometries, which are subsequently meshed and necessarily visualised with gmsh.
Thanks, Tyson