<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>38450</bug_id>
          
          <creation_ts>2010-05-02 23:36:12 -0700</creation_ts>
          <short_desc>[Qt] Problem loading multiple pages at once.</short_desc>
          <delta_ts>2014-01-29 07:46:11 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>New Bugs</component>
          <version>420+</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Windows XP</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>INVALID</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Qt, QtTriaged</keywords>
          <priority>P5</priority>
          <bug_severity>Critical</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sean">allmarx</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>allan.jensen</cc>
    
    <cc>allmarx</cc>
    
    <cc>andersca</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>hausmann</cc>
    
    <cc>jturcotte</cc>
    
    <cc>kent.hansen</cc>
    
    <cc>markus</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>220028</commentid>
    <comment_count>0</comment_count>
    <who name="Sean">allmarx</who>
    <bug_when>2010-05-02 23:36:12 -0700</bug_when>
    <thetext>If you try to load two pages at the same time, on two separate QWebViews, you run into some very strange issues.  I think this may be some annoying threading issue deep within the core, but I&apos;m a noob and don&apos;t really know.


Here is a quick test case that makes two QWebViews that each load digg.com.  It logs the output in two QTextEdit windows.

-------------
main.cpp
-------------
#include &lt;QtGui/QApplication&gt;
#include &quot;logger.h&quot;

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    for (int i = 0; i &lt; 2; ++i)
    {
        Logger *log = new Logger();
        QWebView *web = new QWebView();
        QObject::connect(web, SIGNAL(loadFinished(bool)), log, SLOT(onLoadFinished(bool)));
        web-&gt;load(QUrl(&quot;http://digg.com&quot;));
        log-&gt;show();
    }

    return a.exec();
}

------------
logger.h
------------
#ifndef LOGGER_H
#define LOGGER_H

#include &lt;QTextEdit&gt;
#include &lt;QWebView&gt;
#include &lt;QWebFrame&gt;

class Logger : public QTextEdit
{
Q_OBJECT
public:
    Logger(QWidget *p = 0) : QTextEdit(p) {}
public slots:
    void onLoadFinished(bool ok)
    {
        if (ok)
            this-&gt;append(&quot;Load successful&quot;);
        else
            this-&gt;append(&quot;Load failed&quot;);

        QString html = ((QWebView*)sender())-&gt;page()-&gt;mainFrame()-&gt;toHtml();
        int htmlSize = (html.isNull() || html.isEmpty()) ? 0 : html.length();
        this-&gt;append(QString(&quot;Html size: %1&quot;).arg(htmlSize));
    }
};

#endif // LOGGER_H

--


-- Expected Output: --

*Log 1 and 2*
Load successful
Html size: 92735


-- Actual Output: --

*Log 1*
Load successful
Html size: 92735

*Log 2*
Load successful
Html size: 2057
Load successful
Html size: 92571
Load successful
Html size: 92735


-


Other notes:

This appears to work as expected for google.com (your results may vary), but digg.com and other websites will fail.  Not sure what the common factor is.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>220036</commentid>
    <comment_count>1</comment_count>
    <who name="Markus Goetz">markus</who>
    <bug_when>2010-05-03 00:11:46 -0700</bug_when>
    <thetext>Which Qt version are you using?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>220207</commentid>
    <comment_count>2</comment_count>
    <who name="Sean">allmarx</who>
    <bug_when>2010-05-03 11:25:53 -0700</bug_when>
    <thetext>4.6.2</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>220363</commentid>
    <comment_count>3</comment_count>
    <who name="Sean">allmarx</who>
    <bug_when>2010-05-03 16:37:40 -0700</bug_when>
    <thetext>Okay, this is an obvious issue with the JavaScript core.  With JS disabled, the expected results are obtained.

However, permanently disabling JS is an ugly hack that is not an option for many applications.

This should perhaps be the #1 issue to fix for QtWebKit in my opinion.  When two separate QWebViews can&apos;t even load a page and parse JavaScript simultaneously without disrupting each other in subtle ways, how can we expect tabbed browsers to operate correctly?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>221602</commentid>
    <comment_count>4</comment_count>
    <who name="Kent Hansen">kent.hansen</who>
    <bug_when>2010-05-06 03:21:26 -0700</bug_when>
    <thetext>I can reproduce on Linux against trunk (r58872).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>221721</commentid>
    <comment_count>5</comment_count>
    <who name="Kent Hansen">kent.hansen</who>
    <bug_when>2010-05-06 09:21:43 -0700</bug_when>
    <thetext>digg.com creates several iframes. Every time a frame has loaded, this is reported to FrameLoaderClientQt. And FrameLoaderClientQt::postProgressFinishedNotification() decides to emit loadFinished() for more than one frame.

Modifying the testcase to connect to view-&gt;page()-&gt;mainFrame()&apos;s loadFinished() signal reveals that it&apos;s the &quot;Load successful, Html size: 2057&quot; that comes from the mainframe of one view, the two other signals are due to other frames.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>221869</commentid>
    <comment_count>6</comment_count>
    <who name="Sean">allmarx</who>
    <bug_when>2010-05-06 12:01:54 -0700</bug_when>
    <thetext>Not saying your hypothesis is wrong, in fact it makes a lot of sense, but just wondering how come one of the Loggers only emits 1 load while the other does many?  Theoretically they are loading the same page...?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>221877</commentid>
    <comment_count>7</comment_count>
    <who name="Sean">allmarx</who>
    <bug_when>2010-05-06 12:08:37 -0700</bug_when>
    <thetext>Also I think the HTML size 2057 is === to an empty string (iirc the MAX_STRING &quot;buffer&quot; is like 2058 or something?), because when I try to print it, it&apos;s blank.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>227295</commentid>
    <comment_count>8</comment_count>
      <attachid>56371</attachid>
    <who name="Kent Hansen">kent.hansen</who>
    <bug_when>2010-05-18 07:28:37 -0700</bug_when>
    <thetext>Created attachment 56371
Gtk testcase

Similar testcase for Gtk. Output:

0x960a808 load status changed: 0
0x960a8e0 load status changed: 0
0x960a808 load status changed: 1
0x960a8e0 load status changed: 1
0x960a8e0 load status changed: 2
load_finished_cb(0x960a8e0, 0x9625b80)
0x960a808 load status changed: 3
0x960a8e0 load status changed: 3
load_finished_cb(0x960a8e0, 0x963c2f0)
0x960a808 load status changed: 2
load_finished_cb(0x960a808, 0x9621f80)

So load-finished is emitted twice for one of the views.
And the load-status change order seems fishy for one of the views too (WEBKIT_LOAD_FINISHED before WEBKIT_LOAD_FIRST_VISUALLY_NON_EMPTY_LAYOUT). With only one view this is the output (which is fine):

0x9bdb808 load status changed: 0
0x9bdb808 load status changed: 1
0x9bdb808 load status changed: 3
0x9bdb808 load status changed: 2
load_finished_cb(0x9bdb808, 0x9bf3380)

Either Qt and Gtk are both doing something wrong, or the bug is deeper in WebCore. For sure, WebCore/loader/ProgressTracker.cpp is calling finalProgressComplete() more than once; this is what causes the multiple loadFinished() / load-finished signals. ProgressTracker is associated with a Page, not Frame, so that seems wrong.
For what it&apos;s worth, it looks like the page is eventually loading correctly in both views, it&apos;s just the progress notification that&apos;s incorrect.
Could it be that digg lazily creates some frames/content from JS, and the WebKit loader can&apos;t anticipate this?

Who wants to try it with a WebView on Mac to see how many times a WebViewProgressFinishedNotification is posted?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>782387</commentid>
    <comment_count>9</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2012-12-04 01:54:55 -0800</bug_when>
    <thetext>I am pretty sure this is expected behavior. A scripted webpage can finish loading, then fire a timeout that causes more content to be required to be loaded, and then finish loading that, finishing a second time. 

Pages that dynamically loads content is going to finish loading several times.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>782394</commentid>
    <comment_count>10</comment_count>
    <who name="Jocelyn Turcotte">jturcotte</who>
    <bug_when>2012-12-04 02:08:41 -0800</bug_when>
    <thetext>(In reply to comment #9)
&gt; I am pretty sure this is expected behavior. A scripted webpage can finish loading, then fire a timeout that causes more content to be required to be loaded, and then finish loading that, finishing a second time. 
&gt; 
&gt; Pages that dynamically loads content is going to finish loading several times.

loadFinished should only be emitted at the end of provisional load, there should be no signal after the initial load. Unless if a new subframe is created, which produces the behavior explained in comment #5.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>56371</attachid>
            <date>2010-05-18 07:28:37 -0700</date>
            <delta_ts>2010-05-18 07:28:37 -0700</delta_ts>
            <desc>Gtk testcase</desc>
            <filename>main.c</filename>
            <type>text/x-csrc</type>
            <size>1639</size>
            <attacher name="Kent Hansen">kent.hansen</attacher>
            
              <data encoding="base64">I2luY2x1ZGUgPGd0ay9ndGsuaD4KI2luY2x1ZGUgPHdlYmtpdC93ZWJraXQuaD4KCnZvaWQgbG9h
ZF9maW5pc2hlZF9jYihXZWJLaXRXZWJWaWV3ICp3ZWJfdmlldywKICAgICAgICAgICAgICAgICAg
ICAgIFdlYktpdFdlYkZyYW1lICpmcmFtZSwKICAgICAgICAgICAgICAgICAgICAgIGdwb2ludGVy
IHVzZXJfZGF0YSkKewogICAgZnByaW50ZihzdGRvdXQsICJsb2FkX2ZpbmlzaGVkX2NiKCVwLCAl
cClcbiIsIHdlYl92aWV3LCBmcmFtZSk7Cn0KCnZvaWQgbm90aWZ5X2xvYWRfc3RhdHVzX2NiKFdl
YktpdFdlYlZpZXcgKndlYl92aWV3LAogICAgICAgICAgICAgICAgICAgICAgICAgICBHUGFyYW1T
cGVjICphcmcxLAogICAgICAgICAgICAgICAgICAgICAgICAgICBncG9pbnRlciB1c2VyX2RhdGEp
CnsKICAgIGZwcmludGYoc3Rkb3V0LCAiJXAgbG9hZCBzdGF0dXMgY2hhbmdlZD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5lY3QgKEdf
T0JKRUNUICh3ZWJfdmlldyksICJub3RpZnk6OmxvYWQtc3RhdHVzIiwgR19DQUxMQkFDSyAobm90
aWZ5X2xvYWRfc3RhdHVzX2NiKSwgTlVMTCk7CgogICAgICAgIC8qIE9wZW4gYSB3ZWJwYWdlICov
CiAgICAgICAgd2Via2l0X3dlYl92aWV3X2xvYWRfdXJpIChXRUJLSVRfV0VCX1ZJRVcgKHdlYl92
aWV3KSwgImh0dHA6Ly9kaWdnLmNvbSIpOwoKICAgICAgICAvKiBTaG93IHRoZSByZXN1bHQgKi8K
ICAgICAgICBndGtfd2luZG93X3NldF9kZWZhdWx0X3NpemUgKEdUS19XSU5ET1cgKG1haW5fd2lu
ZG93KSwgODAwLCA2MDApOwogICAgICAgIGd0a193aWRnZXRfc2hvd19hbGwgKG1haW5fd2luZG93
KTsKICAgIH0KICAgIGd0a19tYWluICgpOwoKICAgIHJldHVybiAwOwp9Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>