Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtWebEngine stops displaying when undocked



  • Situation:

    I have an application with a OpenGL widget for 3d visuals (QGLWidget) Next to that there is a QtWebEngine in a dock-widget.
    This works fine until the dock-widget is undocked/undocked. At that moment the WebEngine widget stops functioning.
    If the initial condition of the dock-widget is docked, then the contents will only be displayed when the widget is docked.
    If the initial condition of the dock-widget is floating, then the contents will only be displayed when the widget is floating.

    UGev91ijoB.gif .

    Maybe both QT and the html renderer are both trying to use the same hardware accelerated drawing routines and this fails when they are not in the same window....?

    Windows 10
    Qt 5.12.5
    PySide 5.13.2

    The code to reproduce is:

    from PySide2.QtWidgets import QMainWindow
    from PySide2 import QtCore, QtWidgets
    from PySide2.QtOpenGL import QGLWidget
    
    class Ui_MainWindow(object):
        def setupUi(self, MainWindow):
    
            self.frame3d = QGLWidget(MainWindow)
            MainWindow.setCentralWidget(self.frame3d)
    
            self.info_browser = QtWidgets.QDockWidget(MainWindow)
            self.info_browser.setObjectName("info_browser")
    
            self.dockWidgetContents = QtWidgets.QWidget()
            self.dockWidgetContents.setObjectName("dockWidgetContents")
    
            self.verticalLayout_6 = QtWidgets.QVBoxLayout(self.dockWidgetContents)
    
            self.browser = QWebEngineView(self.dockWidgetContents)
            self.verticalLayout_6.addWidget(self.browser)
            self.info_browser.setWidget(self.dockWidgetContents)
    
            MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(1), self.info_browser)
    
            # self.info_browser.setFloating(True)
    
        def changed(self):
            print('changed')
    
    
    from PySide2.QtWebEngineWidgets import QWebEngineView
    from PySide2.QtWebEngine import QtWebEngine
    
    QtWebEngine.initialize()
    
    app = QtWidgets.QApplication()
    
    
    
    MainWindow = QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    
    
    html = "<html><body><H1>Hello, world</H1>When docked, this is displayed ok, when undocked I'm gone :-(</body></html>"
    
    ui.browser.setHtml(html)
    
    
    MainWindow.show()
    app.exec_()
    


  • @VirtualFloat In Linux I don't see the same problem but rather that the QDockWidget container creates a bad copy, I think the bug is caused by vtk since if I change self.frame3d = QVTKRenderWindowInteractor(MainWindow) to self.frame3d = QtWidgets.QWidget(MainWindow) the problem is no longer observed.



  • @eyllanesc , thanks for looking into this.

    I did dig into the VTK code and it turn out that QVTKRenderWindowInteractor is derived from QGLWidget.

    When I replace QVTKRenderWindowInteractor with QGLWidget the problem remains unchanged. So the problem has to be within Qt.

    Updated the starting post accordingly.


  • Lifetime Qt Champion

    Hi,

    How did you install PySide2 ?



  • @VirtualFloat What happens if you use QWidget instead of QGLWidget?



  • @eyllanesc With QWidget instead of QGLWidget everything works as it should

    @SGaist I installed pyside2 via conda-forge
    version 5.13.2
    qt came from conda-forge as well, version 5.12.5



  • @VirtualFloat It seems the problem is OpenGL. Try not using conda but using python + pip (I've seen several posts caused by conda bugs). In linux with the latest version provided by pip I don't see that problem



  • I'm working with a few different conda environments and I can not risk messing that up by installing qt using pip. I only have one windows PC, and I think a virtual desktop is not going to work here because opengl will be handled differently there.


  • Lifetime Qt Champion

    Hi,

    Use virtenv to create a classic python virtual environment and you won't have to mess with your conda installation.


  • Lifetime Qt Champion

    @VirtualFloat said in QtWebEngine stops displaying when undocked:

    I think a virtual desktop is not going to work here because opengl will be handled differently there.

    Just as a note:
    Depends on your OpenGL requirements.
    Vmware workstation allows openGl 3.3
    and so far only thing that didnt work for me was subsampling.



  • Thanks for the help. I did the following:

    • Created a virtual environement using python -m venv test
    • activated it
    • installed pyside2 using pip install pyside2

    problem persists unchanged, but now I'm also receiving the following error message in the console:

    qt.qpa.backingstore: composeAndFlush: makeCurrent() failed.

    This error is given about 4 times on each un-dock action (so when it stops working).
    When docking (when the browser starts working again) the error is not given.

    pip list
    Package Version


    pip 19.0.3
    PySide2 5.14.2
    setuptools 40.8.0
    shiboken2 5.14.2


Log in to reply