3333from mne .viz ._figure import BrowserBase
3434from mne .viz .backends ._utils import _init_mne_qtapp , _qt_raise_window
3535from mne .viz .utils import _merge_annotations , _simplify_float
36+ from packaging .version import parse
3637from pyqtgraph import (
3738 InfiniteLine ,
3839 PlotItem ,
3940 Point ,
4041 mkPen ,
4142 setConfigOption ,
4243)
43- from qtpy import API_NAME
44+ from qtpy import API_NAME , QT_VERSION
4445from qtpy .QtCore import (
4546 QEvent ,
4647 QSettings ,
@@ -459,38 +460,17 @@ def __init__(self, **kwargs):
459460 self ._add_scalebars ()
460461
461462 # Check for OpenGL
462- # If a user doesn't specify whether or not to use it:
463- # 1. If on macOS, enable it by default to avoid segfault
464- # 2. Otherwise, disable it (performance differences seem minimal, and PyOpenGL
465- # is an optional requirement)
463+ # If a user doesn't specify whether or not to use it, disable it (performance
464+ # differences seem minimal, and PyOpenGL is an optional requirement)
466465 opengl_key = "MNE_BROWSER_USE_OPENGL"
467466 if self .mne .use_opengl is None : # default: opt-in
468- # OpenGL needs to be enabled on macOS
469- # (https://github.com/mne-tools/mne-qt-browser/issues/53)
470- default = "true" if platform .system () == "Darwin" else ""
471- config_val = get_config (opengl_key , default ).lower ()
467+ config_val = get_config (opengl_key , "" ).lower ()
472468 self .mne .use_opengl = config_val == "true"
473469
474470 if self .mne .use_opengl :
475471 try :
476472 import OpenGL
477- except (ModuleNotFoundError , ImportError ) as exc :
478- # On macOS, if use_opengl is True we raise an error because it can lead
479- # to segfaults. If a user really knows what they are doing, they can
480- # pass use_opengl=False (or set MNE_BROWSER_USE_OPENGL=false)
481- if platform .system () == "Darwin" :
482- raise RuntimeError (
483- "Plotting on macOS without OpenGL may be unstable! "
484- "We recommend installing PyOpenGL, but it could not "
485- f"be imported, got:\n { exc } \n \n "
486- "If you want to try plotting without OpenGL, "
487- "you can pass use_opengl=False (use at your own "
488- "risk!). If you know non-OpenGL plotting is stable "
489- "on your system, you can also set the config value "
490- f"{ opengl_key } =false to permanently change "
491- "the default behavior on your system."
492- ) from None
493- # otherwise, emit a warning
473+ except (ModuleNotFoundError , ImportError ):
494474 warn (
495475 "PyOpenGL was not found and OpenGL cannot be used. "
496476 "Consider installing pyopengl with pip or conda or set "
@@ -499,6 +479,19 @@ def __init__(self, **kwargs):
499479 self .mne .use_opengl = False
500480 else :
501481 logger .info (f"Using pyopengl with version { OpenGL .__version__ } " )
482+ # detect a problematic config
483+ if (
484+ platform .system () == "Darwin"
485+ and parse (QT_VERSION ) >= parse ("6.10.0" )
486+ and self .mne .use_opengl
487+ and not check_version ("pyqtgraph" , "0.13.8" )
488+ ): # pragma: no cover
489+ warn (
490+ "On macOS, Qt 6.10.0, pyqtgraph < 0.13.8, with use_opengl=True results "
491+ f"in very slow performance. Consider downgrading { API_NAME } , "
492+ "setting use_opengl=False (which can hurt performance), or "
493+ "upgrading pyqtgraph once 0.13.8 is released"
494+ )
502495 # Initialize BrowserView (inherits QGraphicsView)
503496 self .mne .view = BrowserView (
504497 self .mne .plt , useOpenGL = self .mne .use_opengl , background = "w"
0 commit comments