Open mcgoldba opened 3 years ago
I've noticed this on my end as well and I'm looking into it.
It seems that this is still an issue with the newest release of pyvista (0.32.1). However, I have noticed that the issue is with the following lines of code in plotting.py
(or maybe in the call to the IsCurrent()
vtk function):
If I comment out these lines, the script above works. Since, as I understand, this check is only performed for the benefit of the Windows operating system, can it rather check for the operating system, and then check for the value of IsCurrent()
? Something similar to:
if os.name =='nt' and not self.ren_win.IsCurrent():
...
Just for completeness, in my instance, the call to self.ren_win
returns a vtkXOpenGLRenderWindow
, and the call to IsCurrent()
always returns False
:
import pyvista as pv
print(pv.Report())
pl = pv.Plotter()
_ = pl.add_mesh(pv.Cube())
print(pl.ren_win)
print(pl.ren_win.IsCurrent())
pl.show(auto_close=False)
print(pl.ren_win.IsCurrent())
pl.show(screenshot='my_image.png')
--------------------------------------------------------------------------------
Date: Thu Oct 07 15:00:56 2021 EDT
OS : Linux
CPU(s) : 24
Machine : x86_64
Architecture : 64bit
Environment : Python
GPU Vendor : NVIDIA Corporation
GPU Renderer : Quadro M2000/PCIe/SSE2
GPU Version : 4.5.0 NVIDIA 460.84
Python 3.9.5 (default, Jun 4 2021, 12:28:51) [GCC 7.5.0]
pyvista : 0.32.1
vtk : 9.0.20210710
numpy : 1.21.0
imageio : 2.9.0
appdirs : 1.4.4
scooby : 0.5.7
meshio : 4.4.6
matplotlib : 3.4.2
colorcet : 1.0.0
--------------------------------------------------------------------------------
vtkXOpenGLRenderWindow (0x55641b74d630)
Debug: Off
Modified Time: 4443
Reference Count: 2
Registered Events: (none)
Erase: On
Window Name: Visualization Toolkit - OpenGL
Position: (0, 0)
Size: (1024, 768)
Mapped: 0
ShowWindow: 1
UseOffScreenBuffers: 0
Double Buffered: 1
DPI: 72
TileScale: (1, 1)
TileViewport: (0, 0, 1, 1)
Borders: On
Double Buffer: On
Full Screen: Off
Renderers:
Debug: Off
Modified Time: 3401
Reference Count: 1
Registered Events: (none)
Number Of Items: 2
Stereo Capable Window Requested: No
Stereo Render: Off
Point Smoothing: Off
Line Smoothing: Off
Polygon Smoothing: Off
Abort Render: 0
Current Cursor: 0
Desired Update Rate: 0.0001
In Abort Check: 0
NeverRendered: 1
Interactor: 0x55641b74c3a0
Swap Buffers: On
Stereo Type: RedBlue
Number of Layers: 2
AlphaBitPlanes: On
UseSRGBColorSpace: Off
AnaglyphColorSaturation: 0.65
AnaglyphColorMask: 4 , 3
MultiSamples: 4
StencilCapable: False
ContextId: 0
Color Map: 0
Display Id: 0
Next Window Id: 0
Window Id: 0
False
False
If I comment out these lines, the script above works. Since, as I understand, this check is only performed for the benefit of the Windows operating system, can it rather check for the operating system, and then check for the value of IsCurrent()?
That's a good workaround. I'm finding it annoying locally that auto_close
isn't working.
I just ran into this as well
@mcgoldba Do you still experiences this issue with the following code ? (taken from documentation here).
import pyvista as pv
pl = pv.Plotter()
_ = pl.add_mesh(pv.Cube())
pl.show(auto_close=False)
pl.show(screenshot='my_image.png')
On my side, I obtain the exact same error as you when you posted this issue.
My pv.Report()
:
--------------------------------------------------------------------------------
Date: Fri Jun 23 18:28:22 2023 CEST
OS : Linux
CPU(s) : 8
Machine : x86_64
Architecture : 64bit
RAM : 15.5 GiB
Environment : Jupyter
File system : ext4
GPU Vendor : Intel
GPU Renderer : Mesa Intel(R) HD Graphics 630 (KBL GT2)
GPU Version : 4.6 (Core Profile) Mesa 21.2.6
MathText Support : False
Python 3.9.17 (main, Jun 6 2023, 20:11:04) [GCC 9.4.0]
pyvista : 0.40.dev0
vtk : 9.2.6
numpy : 1.25.0
matplotlib : 3.7.1
scooby : 0.7.2
pooch : v1.7.0
imageio : 2.31.1
IPython : 8.14.0
colorcet : 3.0.1
cmocean : v3.0.3
ipyvtklink : 0.2.3
ipywidgets : 7.7.5
tqdm : 4.65.0
meshio : 5.3.4
pythreejs : 2.4.2
pytest_pyvista : 0.1.8
trame : 2.5.0
trame_client : 2.9.4
trame_server : 2.11.4
trame_vtk : 2.5.0
nest_asyncio : 1.5.6
--------------------------------------------------------------------------------
@beroda as we discussed in slack, I also see the issue. I checked out e65873eff2c67e83888e9ba22af8e6eceee673e8 (corresponding to #3889 that fixed this), and indeed the issue wasn't there. So this is a regression.
git bisect
tells me the regression happened in #4102, looks good based on the name of the PR. cc @akaszynski
Actually, I installed VTK 9.2.2 instead of 9.2.6 (or 9.2.4) and I still see the issue, despite the change in the suspected PR. So that PR might be a red herring on my VTK 9.2.6. Will rerun git bisect
...
Yup, with VTK 9.2.2 the issue wasn't fixed by #3889 in the first place.
Ran git bisect
and came to the same conclusion. Regression introduced in #4102.
@akaszynski I think that PR only reintroduced the regression for VTK 9.2.4 and above, see my previous two comments.
I'm currently facing this error on windows with pyvista==0.44.1
and and vtk==9.3.1
.
I took the docstring for granted and had a headache to understand why things were not working as expected!
If this is the expected behavior for windows, let me know and I can update the docstring accordingly.
Edit: Seems like there is also an issue as I also had the same issue with WSL
Describe the bug, what's wrong, and what you expect:
I have a number of existing scripts that worked on a Windows machine and an older version of pyVista (I do not know which version as that computer had hard drive issues, and was cleaned).
The problem seems to be that the initial call to
p.show(auto_close=False)
still closes the plotter, and subsequent calls top.show(screenshot='image.png')
return an error.To Reproduce
This behavior is reproduced with the code included in the PyVista
Plotter()
documentation:which results in the following error after closing the interactive window (by pressing the
q
button):System Information: