Bug 87037

Summary: [Qt][WK2] ASSERT in QWebIconImageProvider::requestImage()
Product: WebKit Reporter: zalan <zalan>
Component: WebKit2Assignee: Tor Arne Vestbø <vestbo>
Status: RESOLVED INVALID    
Severity: Normal CC: hausmann, menard, vestbo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 87133    
Bug Blocks:    

Description zalan 2012-05-21 12:17:38 PDT
ASSERTION FAILED: !icon.isNull()
/home/zbujtas/WebKit/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp(60) : virtual QImage QWebIconImageProvider::requestImage(const QString&, QSize*, const QSize&)
1   0x7f4a88c822f6 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN21QWebIconImageProvider12requestImageERK7QStringP5QSizeRKS3_+0x2ae) [0x7f4a88c822f6]
2   0x7f4a86bad207 /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(+0x12c207) [0x7f4a86bad207]
3   0x7f4a86bae54e /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(_ZN12QQuickPixmap4loadEP10QQmlEngineRK4QUrlRK5QSize6QFlagsINS_6OptionEE+0x28e) [0x7f4a86bae54e]
4   0x7f4a86cbcf1e /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(_ZN15QQuickImageBase4loadEv+0x1c2) [0x7f4a86cbcf1e]
5   0x7f4a86cbc9be /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(_ZN15QQuickImageBase9setSourceERK4QUrl+0xd0) [0x7f4a86cbc9be]
6   0x7f4a86db85a8 /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(_ZN15QQuickImageBase11qt_metacallEN11QMetaObject4CallEiPPv+0x1dc) [0x7f4a86db85a8]
7   0x7f4a86db8adc /home/zbujtas/qt5/qtbase/lib/libQtQuick.so.5(_ZN11QQuickImage11qt_metacallEN11QMetaObject4CallEiPPv+0x2c) [0x7f4a86db8adc]
8   0x7f4a85f1e810 /home/zbujtas/qt5/qtbase/lib/libQtCore.so.5(_ZN11QMetaObject8metacallEP7QObjectNS_4CallEiPPv+0xa4) [0x7f4a85f1e810]
9   0x7f4a8691715d /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(+0x1d315d) [0x7f4a8691715d]
10  0x7f4a8690e723 /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(+0x1ca723) [0x7f4a8690e723]
11  0x7f4a8690df14 /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(+0x1c9f14) [0x7f4a8690df14]
12  0x7f4a8690de61 /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(+0x1c9e61) [0x7f4a8690de61]
13  0x7f4a86899ca3 /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(_ZN12QQmlNotifier10emitNotifyEP20QQmlNotifierEndpointPPv+0xa3) [0x7f4a86899ca3]
14  0x7f4a867e2431 /home/zbujtas/qt5/qtbase/lib/libQtQml.so.5(_ZN8QQmlData13signalEmittedEP24QAbstractDeclarativeDataP7QObjectiPPv+0x38b) [0x7f4a867e2431]
15  0x7f4a85f564af /home/zbujtas/qt5/qtbase/lib/libQtCore.so.5(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0xc7) [0x7f4a85f564af]
16  0x7f4a88c7ecb3 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN13QQuickWebView11iconChangedEv+0x29) [0x7f4a88c7ecb3]
17  0x7f4a88c79d24 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN20QQuickWebViewPrivate7setIconERK4QUrl+0x172) [0x7f4a88c79d24]
18  0x7f4a88c789fe /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN20QQuickWebViewPrivate26_q_onIconChangedForPageURLERK4QUrlS2_+0x70) [0x7f4a88c789fe]
19  0x7f4a88c7e67f /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(+0x1d3e67f) [0x7f4a88c7e67f]
20  0x7f4a85f56abe /home/zbujtas/qt5/qtbase/lib/libQtCore.so.5(_ZN11QMetaObject8activateEP7QObjectPKS_iPPv+0x6d6) [0x7f4a85f56abe]
21  0x7f4a88d77ca9 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit23QtWebIconDatabaseClient21iconChangedForPageURLERK4QUrlS3_+0x5b) [0x7f4a88d77ca9]
22  0x7f4a88d778e1 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit23QtWebIconDatabaseClient21requestIconForPageURLERK4QUrl+0x2e7) [0x7f4a88d778e1]
23  0x7f4a88d77407 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit23QtWebIconDatabaseClient23didChangeIconForPageURLEPK20OpaqueWKIconDatabasePK11OpaqueWKURLPKv+0x43) [0x7f4a88d77407]
24  0x7f4a88ceb019 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit21WebIconDatabaseClient23didChangeIconForPageURLEPNS_15WebIconDatabaseEPNS_6WebURLE+0x5d) [0x7f4a88ceb019]
25  0x7f4a88ce8726 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit15WebIconDatabase23didChangeIconForPageURLERKN3WTF6StringE+0x4a) [0x7f4a88ce8726]
26  0x7f4a88ce86d0 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN6WebKit15WebIconDatabase27didImportIconDataForPageURLERKN3WTF6StringE+0x2e) [0x7f4a88ce86d0]
27  0x7f4a89b3dcd0 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN7WebCore34ImportedIconDataForPageURLWorkItem11performWorkEv+0x7e) [0x7f4a89b3dcd0]
28  0x7f4a89b3de78 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(+0x2bfde78) [0x7f4a89b3de78]
29  0x7f4a8a2edd18 /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN3WTF31dispatchFunctionsFromMainThreadEv+0x113) [0x7f4a8a2edd18]
30  0x7f4a8a2f8a8d /home/zbujtas/WebKit/WebKitBuild/Debug/lib/libQtWebKit.so.5(_ZN3WTF17MainThreadInvoker5eventEP6QEvent+0x47) [0x7f4a8a2f8a8d]
31  0x7f4a85f1663e /home/zbujtas/qt5/qtbase/lib/libQtCore.so.5(_ZN23QCoreApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x76) [0x7f4a85f1663e]
Comment 1 zalan 2012-05-21 12:33:12 PDT
fails on the following icon request:
qrc:///qml/BrowserWindow.qml:261:13: QML Image: Failed to get image from provider: image://webicon/1/1868935#https://accounts.google.com/ServiceLogin?service=adwords&hl=en_US&ltmpl=jfk&passive=true&ifr=false&alwf=true&continue=https://adwords.google.com/um/gaiaauth?apt=None&ltmpl=jfk&sacu=1&sarp=1&sourceid=awo&subid=ww-ww-et-ads_lrn

repro: load google.com -> click on 'Advertising programs' (bottom-left link) -> scroll a little down and click on 'learn more' (link)
Comment 2 zalan 2012-05-21 13:13:54 PDT
When querying IconDatabase::iconImageForPageURL() for a favicon, it expects the URL in the same format as it was set. 
However, while constructing the following URL 'image://webicon/<context id>/<icon id>#original page url' to utilize qquickpixmapcache, the original page url, as fragment, gets decoded. When setting a fragment, QUrl decodes things like percent character sequences (and some others too). Similar decoding takes place when setting query as part of the url (resolving #)
Here is a quick example:

original url:https://a.b.com/s?s=https://a.b.com/um/g?apt%3DNone#%20and a space 
QUrl using query: image://webicon/a.b/c.html?https://a.b.com/s?s=https://a.b.com/um/g?apt%3DNone%23 and a space
QUrl using fragment: image://webicon/a.b/c.html#https://a.b.com/s?s=https://a.b.com/um/g?apt=None# and a space
KURL using query: image://webicon/a.b/c.html?https://a.b.com/s?s=https://a.b.com/um/g?apt%3DNone#%20and a space
KURL using fragment: image://webicon/a.b/c.html#https://a.b.com/s?s=https://a.b.com/um/g?apt%3DNone#%20and a space

Notice that QUrl decodes some part of the input string, though differently depending on what part of the url is set. However KURL leaves it as is.
This behavior makes us unable to pass url strings as QUrl and expect the url back in the exact same format.
Switching away from QUrl internally (and on API level) can reduce the issues that might arise in the future in this context, however when the url string leaves the boundary of qtwebkit, it's out of our hands. Even if qtwebkit API returned the url as QString, and QWebIconImageProvider::requestImage() also had QString as input parameter for the url, the fact that pixmap cache's internal representation of the url string is a QUrl object makes the API type enforcing useless.
Thoughts?
Comment 3 Simon Hausmann 2012-05-23 03:38:59 PDT
Just for the record, Tor Arne, Zalan and I had a discussion with Thiago and for this particular issue we concluded that the only way to make sure that the web page url we encode _into_ the web icon url is _exactly_ the same that we extract later is by encoding the url in something like base64 before setting the fragment.
Comment 4 Tor Arne Vestbø 2012-05-23 04:43:02 PDT
Fixing this as part of bug 87133
Comment 5 Jocelyn Turcotte 2014-02-03 03:20:59 PST
=== Bulk closing of Qt bugs ===

If you believe that this bug report is still relevant for a non-Qt port of webkit.org, please re-open it and remove [Qt] from the summary.

If you believe that this is still an important QtWebKit bug, please fill a new report at https://bugreports.qt-project.org and add a link to this issue. See http://qt-project.org/wiki/ReportingBugsInQt for additional guidelines.