<?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>170775</bug_id>
          
          <creation_ts>2017-04-12 09:40:53 -0700</creation_ts>
          <short_desc>[JSC][GTK] glib RunLoop does not accept negative start interval</short_desc>
          <delta_ts>2017-06-04 00:34:05 -0700</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>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=171555</see_also>
          <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="Yusuke Suzuki">ysuzuki</reporter>
          <assigned_to name="Yusuke Suzuki">ysuzuki</assigned_to>
          <cc>benjamin</cc>
    
    <cc>buildbot</cc>
    
    <cc>cdumez</cc>
    
    <cc>cgarcia</cc>
    
    <cc>clopez</cc>
    
    <cc>cmarcelo</cc>
    
    <cc>dbates</cc>
    
    <cc>keith_miller</cc>
    
    <cc>mark.lam</cc>
    
    <cc>mcatanzaro</cc>
    
    <cc>msaboff</cc>
    
    <cc>pranjal.jumde</cc>
    
    <cc>saam</cc>
    
    <cc>xan.lopez</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1296750</commentid>
    <comment_count>0</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-12 09:40:53 -0700</bug_when>
    <thetext>[JSC][GTK] glib RunLoop does not accept negative start interval</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1296752</commentid>
    <comment_count>1</comment_count>
      <attachid>306915</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-12 09:51:40 -0700</bug_when>
    <thetext>Created attachment 306915
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1296855</commentid>
    <comment_count>2</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2017-04-12 15:10:05 -0700</bug_when>
    <thetext>What is trying to use a negative start interval? Why should that not result in an assertion?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1296902</commentid>
    <comment_count>3</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-12 18:32:07 -0700</bug_when>
    <thetext>(In reply to Michael Catanzaro from comment #2)
&gt; What is trying to use a negative start interval? Why should that not result
&gt; in an assertion?

In the GCActivityCallback timer, we usually repeatedly invokes the callback with decade, but sometime we would like to invoke the callback soon.
In the code, we calculate the delta in scheduleTimer. But above calculation can result negative interval if enough time is already spent. It is valid. In such a case, we should schedule the timer with 0_s. This patch just does so.

Previously, we directly use glib timer, which does not have any assertion with negative delays. But now, we start using RunLoop::Timer, which has such an assertion. Thus we should have this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297757</commentid>
    <comment_count>4</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-16 06:52:07 -0700</bug_when>
    <thetext>Ping?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297766</commentid>
    <comment_count>5</comment_count>
      <attachid>306915</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-04-16 09:54:16 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));

Why is this needed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297769</commentid>
    <comment_count>6</comment_count>
      <attachid>306915</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-16 10:12:09 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

&gt;&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt;&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));
&gt; 
&gt; Why is this needed?

For `std::max&lt;Seconds&gt;()`, this is because RunLoop::Timer in glib has assumption that incoming interval is not negative.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297773</commentid>
    <comment_count>7</comment_count>
      <attachid>306915</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-04-16 10:14:41 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

&gt;&gt;&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt;&gt;&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));
&gt;&gt; 
&gt;&gt; Why is this needed?
&gt; 
&gt; For `std::max&lt;Seconds&gt;()`, this is because RunLoop::Timer in glib has assumption that incoming interval is not negative.

Why not remove that assumption since it&apos;s wrong? Seems cleaner to me. Numbers less than current time happen for very natural reasons in code.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297774</commentid>
    <comment_count>8</comment_count>
      <attachid>306915</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-16 10:19:46 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

&gt;&gt;&gt;&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt;&gt;&gt;&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));
&gt;&gt;&gt; 
&gt;&gt;&gt; Why is this needed?
&gt;&gt; 
&gt;&gt; For `std::max&lt;Seconds&gt;()`, this is because RunLoop::Timer in glib has assumption that incoming interval is not negative.
&gt; 
&gt; Why not remove that assumption since it&apos;s wrong? Seems cleaner to me. Numbers less than current time happen for very natural reasons in code.

I think `startOneShot(negative)` is ok. But I&apos;m worried about that it becomes a bit ugly semantics when getting `startRepeating(negative)`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297778</commentid>
    <comment_count>9</comment_count>
      <attachid>306915</attachid>
    <who name="Saam Barati">saam</who>
    <bug_when>2017-04-16 11:13:10 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

r=me

&gt;&gt;&gt;&gt;&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt;&gt;&gt;&gt;&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));
&gt;&gt;&gt;&gt; 
&gt;&gt;&gt;&gt; Why is this needed?
&gt;&gt;&gt; 
&gt;&gt;&gt; For `std::max&lt;Seconds&gt;()`, this is because RunLoop::Timer in glib has assumption that incoming interval is not negative.
&gt;&gt; 
&gt;&gt; Why not remove that assumption since it&apos;s wrong? Seems cleaner to me. Numbers less than current time happen for very natural reasons in code.
&gt; 
&gt; I think `startOneShot(negative)` is ok. But I&apos;m worried about that it becomes a bit ugly semantics when getting `startRepeating(negative)`.

Ok. It seems reasonable to me to make the change in startOneShot, but I&apos;ll leave it up to you</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1297949</commentid>
    <comment_count>10</comment_count>
    <who name="Carlos Alberto Lopez Perez">clopez</who>
    <bug_when>2017-04-17 10:59:47 -0700</bug_when>
    <thetext>Could we land this now and leave the improvement over startOneShot() semantics for later? The GTK debug builds are really broken currently.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1298202</commentid>
    <comment_count>11</comment_count>
      <attachid>306915</attachid>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-18 00:18:00 -0700</bug_when>
    <thetext>Comment on attachment 306915
Patch

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

&gt;&gt;&gt;&gt;&gt;&gt; Source/JavaScriptCore/heap/GCActivityCallback.cpp:92
&gt;&gt;&gt;&gt;&gt;&gt; +    m_timer.startOneShot(std::max&lt;Seconds&gt;(secondsUntilFire - delta, 0_s));
&gt;&gt;&gt;&gt;&gt; 
&gt;&gt;&gt;&gt;&gt; Why is this needed?
&gt;&gt;&gt;&gt; 
&gt;&gt;&gt;&gt; For `std::max&lt;Seconds&gt;()`, this is because RunLoop::Timer in glib has assumption that incoming interval is not negative.
&gt;&gt;&gt; 
&gt;&gt;&gt; Why not remove that assumption since it&apos;s wrong? Seems cleaner to me. Numbers less than current time happen for very natural reasons in code.
&gt;&gt; 
&gt;&gt; I think `startOneShot(negative)` is ok. But I&apos;m worried about that it becomes a bit ugly semantics when getting `startRepeating(negative)`.
&gt; 
&gt; Ok. It seems reasonable to me to make the change in startOneShot, but I&apos;ll leave it up to you

OK, I&apos;ll do the both. While accepting negative seconds is ok, I think leaving `std::max&lt;Seconds&gt;()` is good annotation that this may produce negative values.
Since we do not hit that assertion before, it means that all the other places simply uses positive value, it is good.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1298205</commentid>
    <comment_count>12</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2017-04-18 00:26:17 -0700</bug_when>
    <thetext>Note that GSource actually accepts negative values, but with a different meaning. It only accepts -1 to disable the source, which means never fire this. If negative values are allowed by RunLoop in general, and mean fire ASAP, we should handle that case in the runLoop glib implementation by using 0 in such cases.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1298207</commentid>
    <comment_count>13</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-18 00:28:44 -0700</bug_when>
    <thetext>Committed r215454: &lt;http://trac.webkit.org/changeset/215454&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1298221</commentid>
    <comment_count>14</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-04-18 01:08:04 -0700</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #12)
&gt; Note that GSource actually accepts negative values, but with a different
&gt; meaning. It only accepts -1 to disable the source, which means never fire
&gt; this. If negative values are allowed by RunLoop in general, and mean fire
&gt; ASAP, we should handle that case in the runLoop glib implementation by using
&gt; 0 in such cases.

Right. Landed one does so. ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1315395</commentid>
    <comment_count>15</comment_count>
    <who name="Yusuke Suzuki">ysuzuki</who>
    <bug_when>2017-06-03 04:34:12 -0700</bug_when>
    <thetext>*** Bug 170893 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>306915</attachid>
            <date>2017-04-12 09:51:40 -0700</date>
            <delta_ts>2017-04-16 11:13:10 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-170775-20170413015139.patch</filename>
            <type>text/plain</type>
            <size>3163</size>
            <attacher name="Yusuke Suzuki">ysuzuki</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjE1MjY4CmRpZmYgLS1naXQgYS9Tb3VyY2UvSmF2YVNjcmlw
dENvcmUvQ2hhbmdlTG9nIGIvU291cmNlL0phdmFTY3JpcHRDb3JlL0NoYW5nZUxvZwppbmRleCBl
Y2M5NTkyZDc2ZjQ5NWNmMzIwMTEzODM3YzZlM2ViODkwODQ2NzNmLi5kYTZiYjI5YzRkOTQ1NTEy
ODA1MzM1MjFiZGYxZjgzYzVhNDkyNjk2I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ZTgwNTBkMTg3NjBlM2M5NzRiNTcxM2M3OTJjYzVmNSAxMDA2NDQKLS0tIGEvU291cmNlL1dU
Ri93dGYvZ2xpYi9SdW5Mb29wR0xpYi5jcHAKKysrIGIvU291cmNlL1dURi93dGYvZ2xpYi9SdW5M
b29wR0xpYi5jcHAKQEAgLTIxOCw3ICsyMTgsMTAgQEAgYm9vbCBSdW5Mb29wOjpUaW1lckJhc2U6
OmlzQWN0aXZlKCkgY29uc3QKIAogU2Vjb25kcyBSdW5Mb29wOjpUaW1lckJhc2U6OnNlY29uZHNV
bnRpbEZpcmUoKSBjb25zdAogewotICAgIHJldHVybiBzdGQ6Om1heDxTZWNvbmRzPihTZWNvbmRz
Ojpmcm9tTWljcm9zZWNvbmRzKGdfc291cmNlX2dldF9yZWFkeV90aW1lKG1fc291cmNlLmdldCgp
KSAtIGdfZ2V0X21vbm90b25pY190aW1lKCkpLCAwX3MpOworICAgIGdpbnQ2NCB0aW1lID0gZ19z
b3VyY2VfZ2V0X3JlYWR5X3RpbWUobV9zb3VyY2UuZ2V0KCkpOworICAgIGlmICh0aW1lICE9IC0x
KQorICAgICAgICByZXR1cm4gc3RkOjptYXg8U2Vjb25kcz4oU2Vjb25kczo6ZnJvbU1pY3Jvc2Vj
b25kcyh0aW1lIC0gZ19nZXRfbW9ub3RvbmljX3RpbWUoKSksIDBfcyk7CisgICAgcmV0dXJuIDBf
czsKIH0KIAogfSAvLyBuYW1lc3BhY2UgV1RGCg==
</data>
<flag name="review"
          id="328229"
          type_id="1"
          status="+"
          setter="saam"
    />
          </attachment>
      

    </bug>

</bugzilla>