Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.12, 6.2.7, 6.4.2, 6.5.0 Beta2
-
Windows 10 22H2 Pro, MSVC 2019 x64
-
-
889567af4 (112-based), 37430020d (dev)
Description
Code
sample.html
<html><body> <img src="https://www.qt.io/hubfs/2016_Qt_Logo/qt_logo_green_rgb_16x16.png" /> </body></html>
main.cpp
int main(int argc, char* argv[]) { QApplication app(argc, argv); QUrl sampleUrl("qrc:/sample.html"); QWebEnginePage page; page.settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true); QObject::connect(&page, &QWebEnginePage::loadProgress, [](int progress) { qDebug() << "Loading progress:" << progress; }); QObject::connect(&page, &QWebEnginePage::loadFinished, [&] { qDebug("Finished!"); static bool firstReload = true; if (!firstReload) { qDebug("Quitting"); qApp->quit(); return; } qDebug("Clearing cache"); page.profile()->clearHttpCache(); firstReload = false; // WORKAROUND: Wrap the lines below around a QTimer::singleShot() // with a sufficiently large delay (say, 100ms - 500ms) qDebug("Reloading..."); page.load(sampleUrl); }); page.load(sampleUrl); return app.exec(); }
Expected output
Loading progress: 0 Loading progress: 70 Loading progress: 80 Loading progress: 100 Finished! Clearing cache Reloading... Loading progress: 0 Loading progress: 70 Loading progress: 100 Finished! Quitting
Actual output
Loading progress: 0 Loading progress: 70 Loading progress: 80 Loading progress: 100 Finished! Clearing cache Reloading... Loading progress: 0 Loading progress: 80
The 2nd load never finishes so the app never quits.
Notes
- This seems to be some kind of race condition:
- On one Windows 10 PC, I can reproduce this 100% of the time on Qt 6.x, but never on Qt 5.15
- On another Windows 10 PC, I can only reproduce this ~50% of the time on all versions of Qt
- Setting QWebEngineProfile::NoCache seems to have no effect
Workaround?
If we introduce a delay between calling QWebEngineProfile::clearHttpCache() and QWebEnginePage::load(), it seems to work fine.
On my PC, 10ms was still too small while 500ms seemed to be enough that it never hangs.
Attachments
Issue Links
- relates to
-
QTBUG-89670 Create signal out of QtWebProfile for clearHttpCache completion
-
- Closed
-
For Gerrit Dashboard: QTBUG-111541 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
477629,2 | Do not reset network context while loading a page | dev | qt/qtwebengine | Status: ABANDONED | 0 | 0 |
492736,6 | Add clearHttpCacheCompleted signal to profile | dev | qt/qtwebengine | Status: MERGED | +2 | 0 |
493884,3 | Make NetworkContext resettable | 112-based | qt/qtwebengine-chromium | Status: MERGED | +2 | 0 |