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

Unreliable QWebEnginePage::loadFinished signal depending on page content

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.15.5
    • 5.15.0
    • WebEngine
    • None
    • b719da05c6429d72f4e0e0af44da0bf3f3e57984 (qt/qtwebengine/5.15) 4d4fc9cd120376f30ce0630b1e8c7bf174d44fae (qt/qtwebengine/5.15)

    Description

      General Description

      We recently found that we cannot reliably rely on QWebEnginePage::loadFinished to detect when a new page has loaded depending on the page's content. In pages that automatically re-load themselves by submitting a form you may get one or two loadFinished signals depending on whether that page includes other slow loading content like a gif.

       

      Repro

      I've attached a simple demo project which has two buttons, a webview, and a couple of labels. When you click either button it will load an html page into the webview and record the number of load starts/finishes the page emitted. The two buttons load essentially the same html file - a simple page with a form that issues a GET request against qt.io that is immediately submitted. The one difference is that one page also loads an image tag as well. You'll notice that loading the page with the image will emit exactly one loadStart/loadFinished pair while the page without the image will load two instances of each. We'd expect these pages to emit the same number of these signals as they are loading the same number of pages (2) - loaded content within an individual page doesn't seem like it should change how many pages are considered loaded.

       

       

      Investigation

      This appears to be due to the fact that WebContentsDelegateQt views a page load's lifetime to start from WebContentsDelegateQt::DidStartNavigation until WebContentsDelegateQt::DidFinishLoad. In a fast loading page the sequence of events looks something like this:

       

      QtWebEngineCore::WebContentsDelegateQt::DidStartNavigation (Request 1)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishNavigation (Request 1)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishLoad (Request 1)

       

      QtWebEngineCore::WebContentsDelegateQt::DidStartNavigation (Request 2)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishNavigation (Request 2)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishLoad (Request 2)

       

      so each load interval is distinct.

       

      In the case of the slow loading page with the image it gets more complex:

      QtWebEngineCore::WebContentsDelegateQt::DidStartNavigation (Request 1)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishNavigation (Request 1)

      QtWebEngineCore::WebContentsDelegateQt::DidStartNavigation (Request 2)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishLoad (Request 1)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishNavigation (Request 2)

      QtWebEngineCore::WebContentsDelegateQt::DidFinishLoad (Request 2)

       

      In this case because second StartNavigation happens while Qt considers the first page to still be loading no loadStart is emitted and no new page-load interval is considered to have started. When the DidFinishLoad then comes in it finishes the first load interval. When we later get the DidFinishLoad for the second page Qt swallows it because it doesn't consider Request 2 to be a distinct load interval.

      Attachments

        Issue Links

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

          Activity

            People

              kiburtse Kirill Burtsev
              wmartin Will Martin
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes