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. WebEngine refuses to use GPU
Qt 6.11 is out! See what's new in the release blog

WebEngine refuses to use GPU

Scheduled Pinned Locked Moved Unsolved QtWebEngine
qwebengineviewgpuslowrender
2 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.
  • S Offline
    S Offline
    Steven Larry
    wrote on last edited by
    #1

    I'm just running a minimal example:

    #include <QApplication>
    #include <QWebEngineView>
    #include <QWebEngineSettings>
    #include <QSurfaceFormat>
    
    int main(int argc, char *argv[]) {
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QApplication app(argc, argv);
    
        
        QSurfaceFormat format;
        format.setRenderableType(QSurfaceFormat::OpenGL);
        QSurfaceFormat::setDefaultFormat(format);
    
    
        qputenv("QTWEBENGINE_CHROMIUM_FLAGS", "--enable-gpu-rasterization --enable-zero-copy --ignore-gpu-blacklist");
    
      
        QWebEngineView *view = new QWebEngineView();
        view->settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, true);
        view->settings()->setAttribute(QWebEngineSettings::WebGLEnabled, true);
    
        view->setUrl(QUrl("https://maps.google.com"));
        view->show();
    
        return app.exec();
    }
    

    And noticed the rendering lags badly. As you can see I already tried setting a bunch of flags to force it to use GPU. Checking chrome://gpu (replace the gooogle maps url with it) shows that hardware acceleration is enabled:

    alt text

    But when I check the task manager, the WebEngineProcess shows no gpu loading, and the cpu load is very high.

    Perplexingly, I wrote a python script on the same machine that runs fine and smooth:

    from PyQt5.QtWidgets import QApplication
    from PyQt5.QtWebEngineWidgets import QWebEngineView
    import sys
    from PyQt5.QtCore import QUrl
    import os
    
    
    app = QApplication(sys.argv)
    
    view = QWebEngineView()
    print(os.environ.get("QTWEBENGINE_CHROMIUM_FLAGS"))
    view.setUrl(QUrl("https://maps.google.com"))
    view.show()
    
    sys.exit(app.exec_())
    

    What could be the issue here? Any help would be greatly appreciated.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Steven Larry
      wrote on last edited by
      #2

      Very embarassing but I found out I have to to build in RELEASE mode to have the full GPU acceleration.

      In practice that means doing

      cmake -DCMAKE_BUILD_TYPE=Release ..

      Then run windeployqt again. There should be QWebEngineProcess.exe - if there is QWebEngineProcessd.exe (the d for "debug") that means it is still in debug mode and will be slow.

      1 Reply Last reply
      0

      • Login

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