pyvista / pyvista

3D plotting and mesh analysis through a streamlined interface for the Visualization Toolkit (VTK)
https://docs.pyvista.org
MIT License
2.57k stars 472 forks source link

Terminal hijacking bug with latex-formatted plot labels #5636

Open grosskc opened 6 months ago

grosskc commented 6 months ago

Describe the bug, what's wrong, and what you expected.

My interactive terminal is "hijacked" if I make plots containing latex-formatted labels. Latex-formatted labels are properly rendered only if I import vtk prior to import pyvista as pv or execute pv.Report() prior to making the plot. After closing the plot, I am unable to print anything to my interactive console.

I've attached a small set of steps to reproduce the bug and have attached a screenshot showing the results of running the minimal example code both with and without the line print(pv.Report())

FWIW, I'm using the latest PyCharm and an ipython console on a Mac M2.

Is this related to #4732?

Steps to reproduce the bug.

import numpy as np
import pyvista as pv
from pyvista import examples
print(pv.Report())  # <-- if I comment this out, the "rho" is not rendered correctly but "Hello, world!" prints to the terminal
plotter = pv.Plotter()
plotter.add_text(r'$\rho$')
plotter.show()
print("Hello, world!")  # <-- this doesn't print to the console unless I comment out the `print(pv.Report())` line
mesh = pv.read(examples.planefile)
mesh.transform(np.identity(5))  # <-- intentional error; proper traceback if `print(pv.Report())` line is commented out

System Information

--------------------------------------------------------------------------------
  Date: Fri Feb 16 14:26:59 2024 EST
                OS : Darwin
            CPU(s) : 12
           Machine : arm64
      Architecture : 64bit
               RAM : 96.0 GiB
       Environment : IPython
       File system : apfs
        GPU Vendor : Apple
      GPU Renderer : Apple M2 Max
       GPU Version : 4.1 Metal - 88
  MathText Support : True
  Python 3.10.13 | packaged by conda-forge | (main, Dec 23 2023, 15:35:25)
  [Clang 16.0.6 ]
           pyvista : 0.43.3
               vtk : 9.2.5
             numpy : 1.26.4
        matplotlib : 3.8.3
            scooby : 0.7.1
             pooch : v1.7.0
            pillow : 9.4.0
           imageio : 2.34.0
           IPython : 8.21.0
          colorcet : 3.0.1
        ipywidgets : 8.1.2
             scipy : 1.12.0
              tqdm : 4.66.2
        jupyterlab : 4.1.1
      nest_asyncio : 1.5.6
--------------------------------------------------------------------------------

Screenshots

Screenshot 2024-02-16 at 2 23 52 PM (2)
banesullivan commented 6 months ago

This is highly likely the same as https://github.com/pyvista/pyvista/issues/4732 which at this point I'm pretty sure is an upstream VTK issue with vtkMathTextFreeTypeTextRenderer or some part of text rendering. I recommend reporting this upstream https://gitlab.kitware.com/vtk/vtk/-/issues