Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-109676

QtWebEngine and TranslucentBackground cause high cpu usage when moving the gui

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4.0
    • None
    • Windows 10, Qt 6.4, VS2022
    • Windows

    Description

       

       

       

      While investigating why my gui was using too much CPU when its being moved i found it was being caused by a combination of:

       

      setAttribute(Qt::WA_TranslucentBackground);

      + qtwebengine

       

      I tried to reproduce it in a smaller project and i have been able to reproduce it randomly  with just:

       

      #include <QtWebEngineWidgets/QWebEngineView>
      
      QtWidgetsApplication::QtWidgetsApplication(QWidget *parent)
          : QMainWindow(parent)
      {
          ui.setupUi(this);    
          QWebEngineView* engine = new QWebEngineView(this);  
      }

       

       

      I record a video, its strange that it happens randomly, jump to 1:30:

      https://www.youtube.com/watch?v=g57soYDUV0k

      Just by moving this simple GUI, it causes a huge CPU usage 10%~.

      In some tests i waited some minutes, minimized, resized, etc, but the cpu spike continued.

       

      In my project which contains a lot of widgets it happens 100% of times.

      When i move the GUI it causes a high CPU usage 10%~

       

      When i remove the QWebEngineWidget and move the GUI it uses 1~2%

      It happens with just a simple:

      auto widget = new QWebEngineView(this);

       

      My GUI contains this attribute: 

      setAttribute(Qt::WA_TranslucentBackground); 

      I noted that when i comment on it, the 'bug' doesn't happen, when i move the GUI containing the same QtWebEngine widgets, it uses 2% compared to 10-12% which the attribute set.

       

       

      I figured another way to trigger this 'bug' in a smaller project:

      QtWidgetsApplication7::QtWidgetsApplication7(QWidget *parent)    : QMainWindow(parent)
      {  
        
         ui.setupUi(this);
         setAttribute(Qt::WA_TranslucentBackground);   
         //this->setStyleSheet("background-color: transparent");
      
         QGridLayout* layout = new QGridLayout(ui.centralWidget);   
      
         QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F2), this);    connect(shortcut, &QShortcut::activated, [this]   
         {        
              qDebug() << "shortcut";       
              QWebEngineView* engine = new QWebEngineView();       
              QGridLayout* layout = qobject_cast<QGridLayout*>(ui.centralWidget->layout());    
              layout->addWidget(engine); 
         });
      }
      

      Just hit F2 and move the GUI around, the CPU spikes to 10%~

      https://www.youtube.com/watch?v=qH7mMUf_X0U

       

       

      I also tested on Windows11, on a secondary machine:

      When I add the QWebEngineWidget from 2% it jumps to 20% from just moving the GUI.

      https://www.youtube.com/watch?v=IL3MZyK7wtA

       

       

      In my project when the gui is almost maximized to the entire screen and i move it, sometimes it causes spikes of almost 20% of CPU :/

      I have a i9 9900k this is so much CPU for just moving a simple gui.

       

      Whats happening?

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt_webengine_team Qt WebEngine Team
            cesa caio cesar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes