Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error with pyside2 backend on macOS arm64 #2406

Closed
psobolewskiPhD opened this issue Oct 16, 2022 · 18 comments
Closed

error with pyside2 backend on macOS arm64 #2406

psobolewskiPhD opened this issue Oct 16, 2022 · 18 comments

Comments

@psobolewskiPhD
Copy link
Contributor

Originally I noted this with napari, see: napari/napari#5231

But it seems to be a vispy issue, because if you install:
mamba create --name test-env3 python=3.9 pyside2 vispy
then examples fail, for example https://vispy.org/gallery/scene/turntable_box.html#sphx-glr-gallery-scene-turntable-box-py
Error:
AttributeError: 'CanvasBackendDesktop' object has no attribute 'defaultFramebufferObject'

Traceback (most recent call last):
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 913, in paintGL
    context.flush()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/gloo/wrappers.py", line 573, in flush
    context.flush_commands()  # Process GLIR commands
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/gloo/context.py", line 168, in flush_commands
    fbo = canvas._backend._vispy_get_fb_bind_location()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 875, in _vispy_get_fb_bind_location
    return self.defaultFramebufferObject()
AttributeError: 'CanvasBackendDesktop' object has no attribute 'defaultFramebufferObject'
WARNING: Error drawing visual <vispy.visuals.mesh.MeshVisual object at 0x132dd85b0>
WARNING: Traceback (most recent call last):
  File "/Users/piotrsobolewski/Downloads/turntable_box.py", line 30, in <module>
    canvas.app.run()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/application.py", line 160, in run
    return self._backend._vispy_run()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 335, in _vispy_run
    return exec_func()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 567, in event
    out = super(QtBaseCanvasBackend, self).event(ev)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 903, in paintGL
    self._vispy_canvas.events.draw(region=None)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/util/event.py", line 453, in __call__
    self._invoke_callback(cb, event)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/util/event.py", line 471, in _invoke_callback
    _handle_exception(self.ignore_callback_errors,
  << caught exception here: >>
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/util/event.py", line 469, in _invoke_callback
    cb(event)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/scene/canvas.py", line 218, in on_draw
    self._draw_scene()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/scene/canvas.py", line 277, in _draw_scene
    self.draw_visual(self.scene)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/scene/canvas.py", line 315, in draw_visual
    node.draw()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/scene/visuals.py", line 103, in draw
    self._visual_superclass.draw(self)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/visuals/visual.py", line 605, in draw
    v.draw()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/visuals/visual.py", line 451, in draw
    self._program.draw(self._vshare.draw_mode,
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/visuals/shaders/program.py", line 102, in draw
    Program.draw(self, *args, **kwargs)
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/gloo/program.py", line 526, in draw
    canvas.context.flush_commands()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/gloo/context.py", line 168, in flush_commands
    fbo = canvas._backend._vispy_get_fb_bind_location()
  File "/Users/piotrsobolewski/Dev/miniforge3/envs/test-env3/lib/python3.9/site-packages/vispy/app/backends/_qt.py", line 875, in _vispy_get_fb_bind_location
    return self.defaultFramebufferObject()
AttributeError: 'CanvasBackendDesktop' object has no attribute 'defaultFramebufferObject'
ERROR: Invoking <bound method SceneCanvas.on_draw of <SceneCanvas (PySide2) at 0x1028f5b20>> for DrawEvent

Env details:
pyside2 5.15.6 py39hf5e3978_2 conda-forge
vispy 0.11.0 py39h04ce77e_0 conda-forge

note that mamba create --name test-env3 python=3.9 pyqt vispy
works fine with

╰─ conda list | grep pyqt                                         (test-env3) ─╯
pyqt                      5.15.7           py39h7fba1b6_1    conda-forge
pyqt5-sip                 12.11.0          py39h23fbdae_1    conda-forge

vispy 0.11.0 py39h04ce77e_0 conda-forge

@djhoese
Copy link
Member

djhoese commented Oct 17, 2022

Do we know if this is specific to MacOS? Specific to ARM64 macs? Specific to the version of Qt that PySide 2 is using?

@djhoese
Copy link
Member

djhoese commented Oct 17, 2022

@psobolewskiPhD
Copy link
Contributor Author

psobolewskiPhD commented Oct 17, 2022

Do we know if this is specific to MacOS? Specific to ARM64 macs? Specific to the version of Qt that PySide 2 is using?

Sorry I don't have access to any other machine at the moment. It could be all of those.
It could also be specific to the pyside2 conda-forge package—I can't install from pip because lack of wheel.
But: napari runs CI tests with pyside2 on ubuntu (PySide2==5.15.2.1) and windows (PySide2==5.15.2.1) and they are fine, so probably mac related? though it could still be version related. And tox uses pip, so it could be conda-forge related...
I'll keep poking around.

Edit: on the napari side, Andy tested with macOS 12.6 but x86 and no issues:
napari/napari#5231 (comment)
So it's related to arm64 pyside2.

@psobolewskiPhD
Copy link
Contributor Author

psobolewskiPhD commented Oct 18, 2022

I ran the pyside2 example: https://github.com/pyside/pyside2-setup/blob/5.15/examples/widgets/widgets/tetrix.py
and it works fine in the conda-forge pyside2 env
image
So maybe it's some interaction between arm64 pyside2 and vispy?

Edit: OpenGL example also works, after installing pyopengl
https://github.com/pyside/pyside2-setup/blob/5.15/examples/opengl/hellogl.py

@djhoese
Copy link
Member

djhoese commented Oct 18, 2022

I could be missing something but I don't see pyside2 wheels for non-intel macs here:

https://pypi.org/project/PySide2/#files

I'm surprised it installed at all.

@psobolewskiPhD
Copy link
Contributor Author

I could be missing something but I don't see pyside2 wheels for non-intel macs here:

https://pypi.org/project/PySide2/#files

I'm surprised it installed at all.

pyside2 is built for arm64 macOS on conda-forge:

Executing the query pyside2

conda-forge/osx-arm64                              @   3.0MB/s  1.3s
conda-forge/noarch                                 @   4.1MB/s  2.7s


 Name    Version Build           Channel              
───────────────────────────────────────────────────────
 pyside2 5.15.6  py310h1ceb87a_0 conda-forge/osx-arm64
 pyside2 5.15.6  py310h1ceb87a_1 conda-forge/osx-arm64
 pyside2 5.15.6  py310h1ceb87a_2 conda-forge/osx-arm64
 pyside2 5.15.6  py38h9ecd3b8_0  conda-forge/osx-arm64
 pyside2 5.15.6  py38h9ecd3b8_1  conda-forge/osx-arm64
 pyside2 5.15.6  py38h9ecd3b8_2  conda-forge/osx-arm64
 pyside2 5.15.6  py39hf5e3978_0  conda-forge/osx-arm64
 pyside2 5.15.6  py39hf5e3978_1  conda-forge/osx-arm64
 pyside2 5.15.6  py39hf5e3978_2  conda-forge/osx-arm64
 pyside2 5.15.5  py310h5219f08_1 conda-forge/osx-arm64
 pyside2 5.15.5  py38h465b20c_1  conda-forge/osx-arm64
 pyside2 5.15.5  py39h46bc059_1  conda-forge/osx-arm64

I hit the issue when napari installed from conda-forge pulled pyside2 backend instead of pyqt5.

@djhoese
Copy link
Member

djhoese commented Oct 18, 2022

Ah sorry, I thought you were making a point between PyPI pyside2 and conda-forge pyside2. I misread that you were running a pysides2-only (no vispy) example.

@djhoese
Copy link
Member

djhoese commented Oct 18, 2022

Looks like that pyside2 opengl example is using the old GL API by using the QGLWidget instead of the newer (Qt 5+) API with QOpenGLWidget like VisPy does:

from PySide2.QtWidgets import QOpenGLWidget as QGLWidget

@psobolewskiPhD
Copy link
Contributor Author

@Czaki is helping with some testing in the napari issue thread:

@psobolewskiPhD could you run this code (from script) and paste output

import qtpy
from vispy import app

# set vispy application to the appropriate qt backend
app.use_app(qtpy.API_NAME)

from vispy.app.backends import _qt as vqt

print("qt new",  vqt.QT5_NEW_API)
print("pyqt6",  vqt.PYQT6_API)
print("pyside6",  vqt.PYSIDE6_API)
print("egl", vqt.USE_EGL)
print("attr",  vqt.QGLWidget, hasattr(vqt.QGLWidget, "defaultFramebufferObject"))

Here's what I get with pyside2
and the env with "napari=*=*pyside2*"

╰─ python test_pyside2.py                                         (test-env2) ─╯
qt new True
pyqt6 False
pyside6 False
egl False
attr <class 'PySide2.QtWidgets.QOpenGLWidget'> False

vs Here's my regular pyqt env:

╰─ python test_pyside2.py                                        (napari-dev) ─╯
qt new True
pyqt6 False
pyside6 False
egl False
attr <class 'PyQt5.QtWidgets.QOpenGLWidget'> True

@Czaki
Copy link
Contributor

Czaki commented Oct 18, 2022

This is pyside2 (probably feedstock) problem.

Here Linux pyside2 output.

$ python py_vispy.py 
qt new True
pyqt6 False
pyside6 False
egl False
attr <class 'PySide2.QtWidgets.QOpenGLWidget'> True

@psobolewskiPhD
Copy link
Contributor Author

psobolewskiPhD commented Oct 18, 2022

What version of pyside2 and installed from where?
Part of the problem testing is that pip pyside is out of date.

@Czaki
Copy link
Contributor

Czaki commented Oct 18, 2022

here output from conda env:

$ python py_vispy.py 
qt new True
pyqt6 False
pyside6 False
egl False
attr <class 'PySide2.QtWidgets.QOpenGLWidget'> True

here env:

Details
$ conda list 
# packages in environment at /home/czaki/mambaforge/envs/napari-pyside:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
alsa-lib                  1.2.7.2              h166bdaf_0    conda-forge
attr                      2.5.1                h166bdaf_1    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2022.9.24            ha878542_0    conda-forge
dbus                      1.13.6               h5008d03_3    conda-forge
expat                     2.4.9                h27087fc_0    conda-forge
fftw                      3.3.10          nompi_hf0379b8_105    conda-forge
font-ttf-dejavu-sans-mono 2.37                 hab24e00_0    conda-forge
font-ttf-inconsolata      3.000                h77eed37_0    conda-forge
font-ttf-source-code-pro  2.038                h77eed37_0    conda-forge
font-ttf-ubuntu           0.83                 hab24e00_0    conda-forge
fontconfig                2.14.0               hc2a2eb6_1    conda-forge
fonts-conda-ecosystem     1                             0    conda-forge
fonts-conda-forge         1                             0    conda-forge
freetype                  2.12.1               hca18f0e_0    conda-forge
freetype-py               2.3.0              pyhd8ed1ab_0    conda-forge
gettext                   0.21.1               h27087fc_0    conda-forge
giflib                    5.2.1                h36c2ea0_2    conda-forge
glib                      2.74.0               h6239696_0    conda-forge
glib-tools                2.74.0               h6239696_0    conda-forge
gst-plugins-base          1.20.3               h57caac4_2    conda-forge
gstreamer                 1.20.3               hd4edc92_2    conda-forge
hsluv                     5.0.2              pyh44b312d_0    conda-forge
icu                       70.1                 h27087fc_0    conda-forge
jack                      1.9.21               h2a1e645_0    conda-forge
jpeg                      9e                   h166bdaf_2    conda-forge
keyutils                  1.6.1                h166bdaf_0    conda-forge
kiwisolver                1.4.4            py39hf939315_0    conda-forge
krb5                      1.19.3               h3790be6_0    conda-forge
lame                      3.100             h166bdaf_1003    conda-forge
ld_impl_linux-64          2.39                 hc81fddc_0    conda-forge
lerc                      4.0.0                h27087fc_0    conda-forge
libblas                   3.9.0           16_linux64_openblas    conda-forge
libcap                    2.66                 ha37c62d_0    conda-forge
libcblas                  3.9.0           16_linux64_openblas    conda-forge
libclang                  14.0.6          default_h2e3cab8_0    conda-forge
libclang13                14.0.6          default_h3a83d3e_0    conda-forge
libcups                   2.3.3                h3e49a29_2    conda-forge
libdb                     6.2.32               h9c3ff4c_0    conda-forge
libdeflate                1.14                 h166bdaf_0    conda-forge
libedit                   3.1.20191231         he28a2e2_2    conda-forge
libevent                  2.1.10               h9b69904_4    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libflac                   1.4.1                h27087fc_0    conda-forge
libgcc-ng                 12.2.0              h65d4601_18    conda-forge
libgfortran-ng            12.2.0              h69a702a_18    conda-forge
libgfortran5              12.2.0              h337968e_18    conda-forge
libglib                   2.74.0               h7a41b64_0    conda-forge
libgomp                   12.2.0              h65d4601_18    conda-forge
libiconv                  1.17                 h166bdaf_0    conda-forge
liblapack                 3.9.0           16_linux64_openblas    conda-forge
libllvm14                 14.0.6               he0ac6c6_0    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libogg                    1.3.4                h7f98852_1    conda-forge
libopenblas               0.3.21          pthreads_h78a6416_3    conda-forge
libopus                   1.3.1                h7f98852_1    conda-forge
libpng                    1.6.38               h753d276_0    conda-forge
libpq                     14.5                 hd77ab85_0    conda-forge
libsndfile                1.1.0                h27087fc_0    conda-forge
libsqlite                 3.39.4               h753d276_0    conda-forge
libstdcxx-ng              12.2.0              h46fd767_18    conda-forge
libtiff                   4.4.0                h55922b4_4    conda-forge
libtool                   2.4.6             h9c3ff4c_1008    conda-forge
libudev1                  249                  h166bdaf_4    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libvorbis                 1.3.7                h9c3ff4c_0    conda-forge
libwebp                   1.2.4                h522a892_0    conda-forge
libwebp-base              1.2.4                h166bdaf_0    conda-forge
libxcb                    1.13              h7f98852_1004    conda-forge
libxkbcommon              1.0.3                he3ba5ed_0    conda-forge
libxml2                   2.10.3               h7463322_0    conda-forge
libxslt                   1.1.35               h8affb1d_0    conda-forge
libzlib                   1.2.13               h166bdaf_4    conda-forge
mpg123                    1.30.2               h27087fc_1    conda-forge
mysql-common              8.0.31               haf5c9bc_0    conda-forge
mysql-libs                8.0.31               h28c427c_0    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
nspr                      4.32                 h9c3ff4c_1    conda-forge
nss                       3.78                 h2350873_0    conda-forge
numpy                     1.23.4           py39h3d75532_0    conda-forge
openssl                   1.1.1q               h166bdaf_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pcre2                     10.37                hc3806b6_1    conda-forge
pip                       22.3               pyhd8ed1ab_0    conda-forge
pthread-stubs             0.4               h36c2ea0_1001    conda-forge
pulseaudio                14.0                habe0971_10    conda-forge
pyparsing                 3.0.9              pyhd8ed1ab_0    conda-forge
pyside2                   5.15.6           py39hbfe2af7_2    conda-forge
python                    3.9.13          h9a8a25e_0_cpython    conda-forge
python_abi                3.9                      2_cp39    conda-forge
qt-main                   5.15.6               hc525480_0    conda-forge
qt-webengine              5.15.4               hcbadb6c_3    conda-forge
qtpy                      2.2.1              pyhd8ed1ab_0    conda-forge
readline                  8.1.2                h0f457ee_0    conda-forge
setuptools                65.5.0             pyhd8ed1ab_0    conda-forge
sqlite                    3.39.4               h4ff8645_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tzdata                    2022e                h191b570_0    conda-forge
vispy                     0.11.0           py39h2afa9b7_0    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
xcb-util                  0.4.0                h516909a_0    conda-forge
xcb-util-image            0.4.0                h166bdaf_0    conda-forge
xcb-util-keysyms          0.4.0                h516909a_0    conda-forge
xcb-util-renderutil       0.3.9                h166bdaf_0    conda-forge
xcb-util-wm               0.4.1                h516909a_0    conda-forge
xorg-libxau               1.0.9                h7f98852_0    conda-forge
xorg-libxdmcp             1.1.3                h7f98852_0    conda-forge
xz                        5.2.6                h166bdaf_0    conda-forge
zstd                      1.5.2                h6239696_4    conda-forge

@psobolewskiPhD
Copy link
Contributor Author

Ok, so generally the same. 🤷‍♂️

@Czaki
Copy link
Contributor

Czaki commented Oct 18, 2022

Also it is mentioned in pyside2 docs:

https://doc.qt.io/qtforpython-5/PySide2/QtWidgets/QOpenGLWidget.html#PySide2.QtWidgets.PySide2.QtWidgets.QOpenGLWidget.defaultFramebufferObject

so it looks like a bug in the build process.

@psobolewskiPhD
Copy link
Contributor Author

psobolewskiPhD commented Oct 29, 2022

FYI: I made a python 3.10 env, which has a different build number for pyside2 and get the same error.
Edit:
Also I've made an emulated (Rosetta2) x86 env, and pyside2 from conda-forge does work with vispy. I think I will open an issue on conda-forge feedstock.

@psobolewskiPhD
Copy link
Contributor Author

Update: it's not a conda-forge specific issue.
pyside2 arm64 from homebrew also has the same problem, see:
napari/packaging#35 (comment)

@psobolewskiPhD psobolewskiPhD changed the title error with conda-forge pyside2 backend on macOS arm64 error with pyside2 backend on macOS arm64 Jan 11, 2023
@psobolewskiPhD
Copy link
Contributor Author

Update2: it's been reported up-stream by Julien Schueller
https://bugreports.qt.io/browse/PYSIDE-2187

@psobolewskiPhD
Copy link
Contributor Author

conda-forge/pyside2-feedstock#175
has been merged and I can confirm the issue is solved!
hasattr(QOpenGLWidget, "defaultFramebufferObject")
reports True on macOS 13.1 arm64 for pyside2 build live on conda-forge.
Everything works as far as I can tell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants