<?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>105348</bug_id>
          
          <creation_ts>2012-12-18 14:14:11 -0800</creation_ts>
          <short_desc>XMLHttpRequestProgressEventThrottle::resume() always schedules timer even when unnecessary</short_desc>
          <delta_ts>2013-02-12 07:12:57 -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>Page Loading</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Yong Li">yong.li.webkit</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>allan.jensen</cc>
    
    <cc>ap</cc>
    
    <cc>jchaffraix</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>794034</commentid>
    <comment_count>0</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2012-12-18 14:14:11 -0800</bug_when>
    <thetext>XMLHttpRequestProgressEventThrottle::resume() currently always books a timer even there is no deferred event to handle.

It should just clear m_deferEvents and return in this case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>794652</commentid>
    <comment_count>1</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2012-12-19 07:28:25 -0800</bug_when>
    <thetext>The patch will be as easy as

::resume()
{
 ...

+ if (no deferred event to dispatch) {
+   clear flag and return;
+ }
 ...

No time today. will post a patch later</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>829825</commentid>
    <comment_count>2</comment_count>
      <attachid>187607</attachid>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2013-02-11 10:06:06 -0800</bug_when>
    <thetext>Created attachment 187607
the patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830132</commentid>
    <comment_count>3</comment_count>
      <attachid>187607</attachid>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-02-11 14:26:59 -0800</bug_when>
    <thetext>Comment on attachment 187607
the patch

View in context: https://bugs.webkit.org/attachment.cgi?id=187607&amp;action=review

Looks right to me.

&gt; Source/WebCore/xml/XMLHttpRequestProgressEventThrottle.cpp:202
&gt; +        // There is no deferred event. Let&apos;s clear the flag now.

I don&apos;t think that this comment is useful. It just describes what the code does.

Please remove the comment before landing.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830148</commentid>
    <comment_count>4</comment_count>
      <attachid>187679</attachid>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2013-02-11 14:38:36 -0800</bug_when>
    <thetext>Created attachment 187679
remove the comment

Thanks Alexey</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830171</commentid>
    <comment_count>5</comment_count>
      <attachid>187679</attachid>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-02-11 14:59:19 -0800</bug_when>
    <thetext>Comment on attachment 187679
remove the comment

Even if no events are deferred yet, they may be before events are starting to be dispatched. In any case no event should be dispatched if none are there at the time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830176</commentid>
    <comment_count>6</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-02-11 15:01:52 -0800</bug_when>
    <thetext>(In reply to comment #0)
&gt; XMLHttpRequestProgressEventThrottle::resume() currently always books a timer even there is no deferred event to handle.
&gt; 

Yes, an instant timer. Please read the comments for it before assuming that is wrong.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830184</commentid>
    <comment_count>7</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2013-02-11 15:08:49 -0800</bug_when>
    <thetext>(In reply to comment #5)
&gt; (From update of attachment 187679 [details])
&gt; Even if no events are deferred yet, they may be before events are starting to be dispatched. In any case no event should be dispatched if none are there at the time.


I&apos;m not sure I get you. But leaving the flag on will automatically defer incoming events, even when not necessary. Deferring events is only needed in special cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830186</commentid>
    <comment_count>8</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2013-02-11 15:10:09 -0800</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #0)
&gt; &gt; XMLHttpRequestProgressEventThrottle::resume() currently always books a timer even there is no deferred event to handle.
&gt; &gt; 
&gt; 
&gt; Yes, an instant timer. Please read the comments for it before assuming that is wrong.

Why should we start the timer if it is not necessary?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830200</commentid>
    <comment_count>9</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-02-11 15:19:48 -0800</bug_when>
    <thetext>The patch may be safe. The reason I paniced and put cq- on it is just to get time to review it tomorrow. The code here was the subject of a large number of race-conditions, and your patch also conflicts a little with comment below it:
// m_deferEvents is kept true until all deferred events have been dispatched.

The problem with resume is that a number of active DOM objects can be resumed at the same time, and the request here can both be cancelled or even suspended again before it has a chance to fully react to resume.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830209</commentid>
    <comment_count>10</comment_count>
      <attachid>187679</attachid>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-02-11 15:27:09 -0800</bug_when>
    <thetext>Comment on attachment 187679
remove the comment

Okay, I have had a few minutes to check it, and I can&apos;t think of a race-condition that could go wrong, yet, but since ap already approved it. I will not hold it back.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830215</commentid>
    <comment_count>11</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2013-02-11 15:28:44 -0800</bug_when>
    <thetext>&gt; your patch also conflicts a little with comment below it:
&gt; // m_deferEvents is kept true until all deferred events have been dispatched.

I don&apos;t think that there is a conflict there. With this change, m_deferEvents is set to false only when there are no deferred events.

Note that this comment disagrees with what XMLHttpRequestProgressEventThrottle::dispatchDeferredEvents() actually does. It sets m_deferEvents to false immediately, and even notes that there may be leftover events remaining in m_deferredEvents.

So I think that this patch is correct, however the code needs another look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830242</commentid>
    <comment_count>12</comment_count>
    <who name="Allan Sandfeld Jensen">allan.jensen</who>
    <bug_when>2013-02-11 15:45:08 -0800</bug_when>
    <thetext>(In reply to comment #11)
&gt; &gt; your patch also conflicts a little with comment below it:
&gt; &gt; // m_deferEvents is kept true until all deferred events have been dispatched.
&gt; 
&gt; I don&apos;t think that there is a conflict there. With this change, m_deferEvents is set to false only when there are no deferred events.
&gt; 
&gt; Note that this comment disagrees with what XMLHttpRequestProgressEventThrottle::dispatchDeferredEvents() actually does. It sets m_deferEvents to false immediately, and even notes that there may be leftover events remaining in m_deferredEvents.
&gt; 
&gt; So I think that this patch is correct, however the code needs another look.

The point in this case is that m_deferEvents means that resume has been called, but dispatchDeferredEvents() has not. This is a half-resumed state that can be cancelled in case something else causes a suspend before dispatchDeferredEvents() has a chance to run.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830273</commentid>
    <comment_count>13</comment_count>
      <attachid>187679</attachid>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2013-02-11 16:03:18 -0800</bug_when>
    <thetext>Comment on attachment 187679
remove the comment

Clearing flags on attachment: 187679

Committed r142538: &lt;http://trac.webkit.org/changeset/142538&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830274</commentid>
    <comment_count>14</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2013-02-11 16:03:23 -0800</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>830920</commentid>
    <comment_count>15</comment_count>
    <who name="Yong Li">yong.li.webkit</who>
    <bug_when>2013-02-12 07:12:57 -0800</bug_when>
    <thetext>Thanks Alan for double checking.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>187607</attachid>
            <date>2013-02-11 10:06:06 -0800</date>
            <delta_ts>2013-02-11 14:38:36 -0800</delta_ts>
            <desc>the patch</desc>
            <filename>105348.diff</filename>
            <type>text/plain</type>
            <size>1750</size>
            <attacher name="Yong Li">yong.li.webkit</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCAxZmVlM2Y1Li4wMWQwZGQ1IDEwMDY0NAotLS0gYS9Tb3VyY2UvV2ViQ29y
ZS9DaGFuZ2VMb2cKKysrIGIvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTgg
QEAKKzIwMTMtMDItMTEgIFlvbmcgTGkgIDx5b2xpQHJpbS5jb20+CisKKyAgICAgICAgWE1MSHR0
cFJlcXVlc3RQcm9ncmVzc0V2ZW50VGhyb3R0bGU6OnJlc3VtZSgpIGFsd2F5cyBzY2hlZHVsZXMg
dGltZXIgZXZlbiB3aGVuIHVubmVjZXNzYXJ5CisgICAgICAgIGh0dHBzOi8vYnVncy53ZWJraXQu
b3JnL3Nob3dfYnVnLmNnaT9pZD0xMDUzNDgKKworICAgICAgICBSZXZpZXdlZCBieSBOT0JPRFkg
KE9PUFMhKS4KKworICAgICAgICBMZXQgcmVzdW1lKCkgY2xlYXIgdGhlIGRlZmVyIGZsYWcgYW5k
IHJldH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dyZXNzRXZlbnRU
aHJvdHRsZTo6cmVzdW1lKCkKICAgICBBU1NFUlQoIW1fbG9hZGVkKTsKICAgICBBU1NFUlQoIW1f
dG90YWwpOwogCisgICAgaWYgKG1fZGVmZXJyZWRFdmVudHMuaXNFbXB0eSgpICYmICFtX2RlZmVy
cmVkUHJvZ3Jlc3NFdmVudCkgeworICAgICAgICAvLyBUaGVyZSBpcyBubyBkZWZlcnJlZCBldmVu
dC4gTGV0J3MgY2xlYXIgdGhlIGZsYWcgbm93LgorICAgICAgICBtX2RlZmVyRXZlbnRzID0gZmFs
c2U7CisgICAgICAgIHJldHVybjsKKyAgICB9CisKICAgICAvLyBEbyBub3QgZGlzcGF0Y2ggZXZl
bnRzIGlubGluZSBoZXJlLCBzaW5jZSBTY3JpcHRFeGVjdXRpb25Db250ZXh0IGlzIGl0ZXJhdGlu
ZyBvdmVyCiAgICAgLy8gdGhlIGxpc3Qgb2YgYWN0aXZlIERPTSBvYmplY3RzIHRvIHJlc3VtZSB0
aGVtLCBhbmQgYW55IGFjdGl2YXRlZCBKUyBldmVudC1oYW5kbGVyCiAgICAgLy8gY291bGQgaW5z
ZXJ0IG5ldyBhY3RpdmUgRE9NIG9iamVjdHMgdG8gdGhlIGxpc3QuCg==
</data>
<flag name="review"
          id="207471"
          type_id="1"
          status="+"
          setter="ap"
    />
    <flag name="commit-queue"
          id="207564"
          type_id="3"
          status="-"
          setter="ap"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>187679</attachid>
            <date>2013-02-11 14:38:36 -0800</date>
            <delta_ts>2013-02-11 16:03:18 -0800</delta_ts>
            <desc>remove the comment</desc>
            <filename>105348.diff</filename>
            <type>text/plain</type>
            <size>1689</size>
            <attacher name="Yong Li">yong.li.webkit</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUx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