Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
6.4.3, 6.5.3
-
None
-
MacBook Pro M1, macOs 13.4.1, Python 3.11
Description
Hello,
I'm using Pyside 6.5.3 and I noted that when using a pygfx widget that use WebGPU, i.e. QWgpuWidget and a QOpenGLWidget as children of the same Widget, e.g. QMainWindow, the QMainWindow stopped refreshing properly.
There was no error or warning message, I then downgraded to Pyside 6.4.3 and started to see those warnings:
QOpenGLContext::makeCurrent() called with non-opengl surface 0x6000039d9e70 QRhiGles2: Failed to make context current. Expect bad things to happen. QOpenGLContext::makeCurrent() called with non-opengl surface 0x6000039d9c30 QRhiGles2: Failed to make context current. Expect bad things to happen. QOpenGLContext::makeCurrent() called with non-opengl surface 0x6000039dd7b0 QRhiGles2: Failed to make context current. Expect bad things to happen. QOpenGLContext::makeCurrent() called with non-opengl surface 0x6000039fed70 QRhiGles2: Failed to make context current. Expect bad things to happen. QOpenGLContext::makeCurrent() called with non-opengl surface 0x6000039fec50 QRhiGles2: Failed to make context current. Expect bad things to happen.
Worth noting that if both widgets live separately there is no problem. Here is some Python code for reproduction:
import pygfx as gfx import random from OpenGL import GL from PySide6 import QtCore, QtWidgets, QtOpenGLWidgets from wgpu.gui.qt import WgpuWidget class OGLWidget(QtOpenGLWidgets.QOpenGLWidget): def initializeGL(self): GL.glClearColor(0.5, 0.5, 1.0, 1.0) class WGLWidget(QtWidgets.QWidget): def __init__(self): super().__init__() self.resize(640, 480) self._button = QtWidgets.QPushButton("Add a line", self) self._button.clicked.connect(self._on_button_click) self._canvas = WgpuWidget(parent=self) self._renderer = gfx.WgpuRenderer(self._canvas) self._scene = gfx.Scene() self._camera = gfx.OrthographicCamera(110, 110) self._canvas.request_draw(self.animate) layout = QtWidgets.QVBoxLayout() self.setLayout(layout) layout.addWidget(self._canvas) layout.addWidget(self._button) def _on_button_click(self): line = gfx.Line( gfx.Geometry( positions=[ [random.uniform(-50, 50), random.uniform(-50, 50), 0] for i in range(8) ] ), gfx.LineMaterial(thickness=3), ) self._scene.add(line) self._canvas.update() def animate(self): self._renderer.render(self._scene, self._camera) class OGLWidgetDockWidget(QtWidgets.QDockWidget): def __init__(self): super().__init__() self._gl = OGLWidget() self.setWidget(self._gl) class WGLWidgetDockWidget(QtWidgets.QDockWidget): def __init__(self): super().__init__() self._wgl = WGLWidget() self.setWidget(self._wgl) class MainWindow(QtWidgets.QMainWindow): def __init__(self): super().__init__() self.setCentralWidget(QtWidgets.QTextEdit()) self._gl_dock = OGLWidgetDockWidget() self.addDockWidget(QtCore.Qt.RightDockWidgetArea, self._gl_dock) self._wgl_dock = WGLWidgetDockWidget() self.addDockWidget(QtCore.Qt.LeftDockWidgetArea, self._wgl_dock) if __name__ == "__main__": app = QtWidgets.QApplication([]) # Two separate widgets works: if False: gl = OGLWidget() gl.show() wgl = WGLWidget() wgl.show() # The two widgets a children of one widget produces warnings and break # the application refresh: else: main = MainWindow() main.show() app.exec()
Requirements:
- PyOpenGL==3.1.7
- PySide6==6.4.3
- pygfx=0.1.14