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

Almost constant rendering delay if QWebEngineView is forced to load an URL while it is inactive and shown again

    XMLWordPrintable

Details

    • Windows

    Description

      I don't know if it is a Chromim thing or a Qt thing since I haven't found a way to force load, e.g. Microsoft Edge, while it is not active. But anyway, there is a reproducer in attachment and the design is that a QStackedWidget with 2 pages is going to show nothing in page 0 and a QWebEngineView in page 1. There is 1 button to switch to empty page 0 and the other button to make QWebEngineView to load an URL. And another connection between "QWebEnginView::loadFinished" and "switching to QStackedWidget page 1", i.e. force showing QWebEnginView upon webpage loaded.

      To reproduce the behavior, the steps are:

      1. Click "load web view" to load the URL
      2. Scroll down to somewhere else than the top of webpage
      3. Click "switch tab" to switch to page 0 (while it is the case, QWebEngineView is inactive and one can confirm from dev tools)
      4. Click "load web view" again to load URL again (and QStackedWidget is going to switch to page 1 automatically later)

      The expected result is that one should see a new webpage being loaded and shown with its top in the view, i.e. the same result as step 1.

      But the actual result is that QWebEningView is going to remain in the old webpage for a while, and then "jumps" back to the top of the webpage (by then it is the expected result).

      As mentioned at the beginning, I am not sure if loading URL while QWebEningView is inactive is something supported or if the behavior is expected. But here is something that I tried but did not work:

      1. Since loading finished does not necessarily mean rendering finished, I tried to add a delay after "loadFinished" signal, like:
            connect(ui.webEngineView, &QWebEngineView::loadFinished, this, [this]() {
                QTimer::singleShot(500, [this]() {
                    ui.stackedWidget->setCurrentIndex(1);
                });
            });
        

        Not only it does not work, but the time remaining in the old webpage is almost constant regardless of delay (500ms, 5000ms, whatever).

      2. Force QWebEngineView to render before showing, like:
            connect(ui.webEngineView, &QWebEngineView::loadFinished, this, [this]() {
                ui.stackedWidget->update(); //or repaint()
                ui.stackedWidget->setCurrentIndex(1);
            });
        

        It does not anyway (but I kind of expect it to fail since update or repaint a hidden QWidget should not be possible.

      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
            luqiaochen Luqiao Chen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes