Repository: mne-tools/mne-python

Issue:
Surfaces and sensors not showing in coregistration/alignment visualization
#### Describe the bug
*Replace this text with a description of the bug.*

Using mne.viz.plot_alignment() (as e.g. in tutorial 20_source_alignment.html only shows landmarks but not surfaces or sensors.
Version 1.0.3 under Linux (Centos 7).

#### Steps to reproduce

tutorial 20_source_alignment.html


#### Expected results

Plots as in tutorial https://mne.tools/stable/auto_tutorials/forward/20_source_alignment.html.


#### Actual results

![image](https://user-images.githubusercontent.com/7878274/182390697-4360b55b-bc20-469c-9a0a-7dc5a0dfe950.png)


#### Additional information

Platform:         Linux-3.10.0-1160.el7.x86_64-x86_64-with-glibc2.17
Python:           3.10.4 | packaged by conda-forge | (main, Mar 24 2022, 17:38:57) [GCC 10.3.0]
Executable:       /imaging/local/software/mne_python/mne1.0.3_0/bin/python
CPU:              x86_64: 20 cores
Memory:           251.7 GB

mne:              1.0.3
numpy:            1.21.6 {blas=NO_ATLAS_INFO, lapack=lapack}
scipy:            1.8.0
matplotlib:       3.5.2 {backend=QtAgg}

sklearn:          1.0.2
numba:            0.55.1
nibabel:          3.2.2
nilearn:          0.9.1
dipy:             1.5.0
cupy:             Not found
pandas:           1.4.2
pyvista:          0.34.0 {OpenGL 3.3 (Core Profile) Mesa 18.3.4 via llvmpipe (LLVM 7.0, 256 bits)}
pyvistaqt:        0.9.0
ipyvtklink:       0.2.2
vtk:              9.1.0
PyQt5:            5.12.3
ipympl:           0.9.1
pooch:            v1.6.0

mne_bids:         0.10
mne_nirs:         0.2.1
mne_features:     0.2
mne_qt_browser:   0.3.1
mne_connectivity: 0.3




Discussion:

Resolving patch:
diff --git a/mne/viz/backends/_pyvista.py b/mne/viz/backends/_pyvista.py
--- a/mne/viz/backends/_pyvista.py
+++ b/mne/viz/backends/_pyvista.py
@@ -26,7 +26,7 @@
 from ...fixes import _point_data, _cell_data, _compare_version
 from ...transforms import apply_trans
 from ...utils import (copy_base_doc_to_subclass_doc, _check_option,
-                      _require_version, _validate_type)
+                      _require_version, _validate_type, warn)
 
 
 with warnings.catch_warnings():
@@ -1206,4 +1206,17 @@ def _is_mesa(plotter):
     # CircleCI's is: "Mesa 20.0.8 via llvmpipe (LLVM 10.0.0, 256 bits)"
     gpu_info = plotter.ren_win.ReportCapabilities()
     gpu_info = re.findall("OpenGL renderer string:(.+)\n", gpu_info)
-    return ' mesa ' in ' '.join(gpu_info).lower().split()
+    gpu_info = ' '.join(gpu_info).lower()
+    is_mesa = 'mesa' in gpu_info.split()
+    if is_mesa:
+        # Try to warn if it's ancient
+        version = re.findall("mesa ([0-9.]+) .*", gpu_info)
+        if version:
+            version = version[0]
+            if _compare_version(version, '<', '18.3.6'):
+                warn(f'Mesa version {version} is too old for translucent 3D '
+                     'surface rendering, consider upgrading to 18.3.6 or '
+                     'later.')
+        else:
+            raise RuntimeError
+    return is_mesa
diff --git a/mne/viz/backends/_qt.py b/mne/viz/backends/_qt.py
--- a/mne/viz/backends/_qt.py
+++ b/mne/viz/backends/_qt.py
@@ -33,7 +33,8 @@
 
 from ._pyvista import _PyVistaRenderer
 from ._pyvista import (_close_3d_figure, _check_3d_figure, _close_all,  # noqa: F401,E501 analysis:ignore
-                       _set_3d_view, _set_3d_title, _take_3d_screenshot)  # noqa: F401,E501 analysis:ignore
+                       _set_3d_view, _set_3d_title, _take_3d_screenshot,  # noqa: F401,E501 analysis:ignore
+                       _is_mesa)  # noqa: F401,E501 analysis:ignore
 from ._abstract import (_AbstractAppWindow, _AbstractHBoxLayout,
                         _AbstractVBoxLayout, _AbstractGridLayout,
                         _AbstractWidget, _AbstractCanvas,


Test patch:
diff --git a/mne/viz/backends/tests/test_renderer.py b/mne/viz/backends/tests/test_renderer.py
--- a/mne/viz/backends/tests/test_renderer.py
+++ b/mne/viz/backends/tests/test_renderer.py
@@ -202,3 +202,20 @@ def fail(x):
     assert get_3d_backend() is None
     with pytest.raises(RuntimeError, match=match):
         _get_renderer()
+
+
+def test_3d_warning(renderer_pyvistaqt, monkeypatch):
+    """Test that warnings are emitted for old Mesa."""
+    fig = renderer_pyvistaqt.create_3d_figure((800, 600))
+    _is_mesa = renderer_pyvistaqt.backend._is_mesa
+    plotter = fig.plotter
+    good = 'OpenGL renderer string: OpenGL 3.3 (Core Profile) Mesa 20.0.8 via llvmpipe (LLVM 10.0.0, 256 bits)\n'  # noqa
+    bad = 'OpenGL renderer string: OpenGL 3.3 (Core Profile) Mesa 18.3.4 via llvmpipe (LLVM 7.0, 256 bits)\n'  # noqa
+    monkeypatch.setattr(plotter.ren_win, 'ReportCapabilities', lambda: good)
+    assert _is_mesa(plotter)
+    monkeypatch.setattr(plotter.ren_win, 'ReportCapabilities', lambda: bad)
+    with pytest.warns(RuntimeWarning, match=r'18\.3\.4 is too old'):
+        assert _is_mesa(plotter)
+    non = 'OpenGL 4.1 Metal - 76.3 via Apple M1 Pro\n'
+    monkeypatch.setattr(plotter.ren_win, 'ReportCapabilities', lambda: non)
+    assert not _is_mesa(plotter)
diff --git a/mne/viz/tests/test_topomap.py b/mne/viz/tests/test_topomap.py
--- a/mne/viz/tests/test_topomap.py
+++ b/mne/viz/tests/test_topomap.py
@@ -339,7 +339,9 @@ def proc_names(x):
 
     p = plt_topomap(times, ch_type='grad', image_interp='cubic',
                     show_names=lambda x: x.replace('MEG', ''))
-    subplot = [x for x in p.get_children() if 'Subplot' in str(type(x))]
+    subplot = [
+        x for x in p.get_children()
+        if any(t in str(type(x)) for t in ('Axes', 'Subplot'))]
     assert len(subplot) >= 1, [type(x) for x in p.get_children()]
     subplot = subplot[0]