Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How to enable WebGL in QWebEngineView?
Forum Update on Monday, May 27th 2025

How to enable WebGL in QWebEngineView?

Scheduled Pinned Locked Moved Unsolved QtWebEngine
4 Posts 1 Posters 1.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by 8Observer8
    #1

    PyQt Version: 6.6.1
    PySide Version: 6.6.1

    Hi,

    I try to enable WebGL in QWebEngineView:

    view.settings().setAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled, True)
    view.setUrl(QUrl("https://get.webgl.org/"))
    

    but it doesn't work:

    09d38444-e4c1-48a7-b993-e4aa92299ce8-image.png

    main.py

    import sys
    
    from PySide6.QtCore import QUrl
    from PySide6.QtWebEngineCore import QWebEngineSettings
    from PySide6.QtWebEngineWidgets import QWebEngineView
    from PySide6.QtWidgets import QApplication, QVBoxLayout, QWidget
    
    
    class Widget(QWidget):
    
        def __init__(self):
            super().__init__()
            self.setWindowTitle("QWebEngineView, PySide6, Python")
            self.resize(650, 400)
    
            layout = QVBoxLayout()
            view = QWebEngineView()
            layout.addWidget(view)
            self.setLayout(layout)
    
            # view.load(QUrl("file:///web-project/index.html"))
            view.settings().setAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled, True)
            print("----------------------")
            print(view.settings().testAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled))
            view.setUrl(QUrl("https://get.webgl.org/"))
    
    if __name__ == "__main__":
        app = QApplication(sys.argv)
        w = Widget()
        w.show()
        sys.exit(app.exec())
    

    Console output:

    D3D11 smoke test failed (failed to create vertex shader)
    ----------------------
    True
    doh set to ""  --  SystemOnly
    D3D11 smoke test failed (failed to create vertex shader)
    js: Unrecognized Content-Security-Policy directive 'image-src'.
    
    1 Reply Last reply
    0
    • 8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by 8Observer8
      #2

      PyQt 6.6.1 behaves exactly the same way:

      d0c60ebf-6e65-4a0d-8902-b687f7d46218-image.png

      Console output:

      D3D11 smoke test failed (failed to create vertex shader)
      ----------------------
      True
      doh set to ""  --  SystemOnly
      D3D11 smoke test failed (failed to create vertex shader)
      js: Unrecognized Content-Security-Policy directive 'image-src'.
      

      main.py

      import sys
      
      from PyQt6.QtCore import QUrl
      from PyQt6.QtWebEngineCore import QWebEngineSettings
      from PyQt6.QtWebEngineWidgets import QWebEngineView
      from PyQt6.QtWidgets import QApplication, QVBoxLayout, QWidget
      
      
      class Widget(QWidget):
      
          def __init__(self):
              super().__init__()
              self.setWindowTitle("QWebEngineView, PyQt6, Python")
              self.resize(650, 400)
      
              layout = QVBoxLayout()
              view = QWebEngineView()
              layout.addWidget(view)
              self.setLayout(layout)
      
              # view.load(QUrl("file:///web-project/index.html"))
              view.settings().setAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled, True)
              print("----------------------")
              print(view.settings().testAttribute(QWebEngineSettings.WebAttribute.WebGLEnabled))
              view.setUrl(QUrl("https://get.webgl.org/"))
      
      if __name__ == "__main__":
          app = QApplication(sys.argv)
          w = Widget()
          w.show()
          sys.exit(app.exec())
      

      PySide 6.1.1 includes WebEngine. For PyQt 6.1.1 the WebEngine must be installed using this command: pip install PyQt6-WebEngine

      1 Reply Last reply
      0
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by
        #3

        I created a question on StackOverflow and added there some additional information: https://stackoverflow.com/questions/77690410/how-to-enable-webgl-in-qwebengineview

        1 Reply Last reply
        0
        • 8Observer88 Offline
          8Observer88 Offline
          8Observer8
          wrote on last edited by 8Observer8
          #4

          This is an answer of @ekhumoro from StackOverflow:

          QTBUG-42182 is quite old, but the last comment there states: "The current status in Qt 5.5 is this: WebGL and accelerated Canvas work with OpenGL and are blacklisted unfortunately for ANGLE and software renderers due to thread synchronization issues with the former and performance issues with the latter.". This would seem to match your setup, but it's unclear whether it affects Qt6 or only applies to Qt5. Another issue is that none of the WebGL tests you did seems able to identify your GPU at all, which doesn't look promising...

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved