<?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>194111</bug_id>
          
          <creation_ts>2019-01-31 13:44:35 -0800</creation_ts>
          <short_desc>Web Inspector: Memory timeline starts from zero when both CPU and Memory timeline are enabled</short_desc>
          <delta_ts>2019-02-01 13:45:09 -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>Web Inspector</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Joseph Pecoraro">joepeck</reporter>
          <assigned_to name="Joseph Pecoraro">joepeck</assigned_to>
          <cc>hi</cc>
    
    <cc>inspector-bugzilla-changes</cc>
    
    <cc>joepeck</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1500756</commentid>
    <comment_count>0</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-31 13:44:35 -0800</bug_when>
    <thetext>Memory timeline starts from zero when both CPU and Memory timeline are enabled

Steps to Reproduce:
1. Inspect this page
2. Show CPU and Memory Timelines
3. Reload page
  =&gt; Memory starts from zero

Notes:
- The ResourceUsageThread starts immediately when the first listener (CPU) is added therefore misses values for the second listener (Memory) until the second sample 500ms later. We should start with a small wait to give multiple unique listeners a chance to register before the first sample.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1500757</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-01-31 13:44:54 -0800</bug_when>
    <thetext>&lt;rdar://problem/47714555&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1500820</commentid>
    <comment_count>2</comment_count>
      <attachid>360786</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-01-31 14:38:37 -0800</bug_when>
    <thetext>Created attachment 360786
[PATCH] Proposed Fix</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1500892</commentid>
    <comment_count>3</comment_count>
      <attachid>360786</attachid>
    <who name="Devin Rousso">hi</who>
    <bug_when>2019-01-31 16:43:48 -0800</bug_when>
    <thetext>Comment on attachment 360786
[PATCH] Proposed Fix

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

rs=me

&gt; Source/WebCore/page/ResourceUsageThread.cpp:85
&gt; +        WTF::sleep(10_ms);

Where did the `10_ms` come from?  Is there any justification as to why that value was chosen?

&gt; Source/WebCore/page/ResourceUsageThread.cpp:127
&gt; +    WTF::sleep(10_ms);

Should we also be waiting in the case that we already have observers?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1501204</commentid>
    <comment_count>4</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-02-01 11:54:57 -0800</bug_when>
    <thetext>(In reply to Devin Rousso from comment #3)
&gt; Comment on attachment 360786 [details]
&gt; [PATCH] Proposed Fix
&gt; 
&gt; View in context:
&gt; https://bugs.webkit.org/attachment.cgi?id=360786&amp;action=review
&gt; 
&gt; rs=me
&gt; 
&gt; &gt; Source/WebCore/page/ResourceUsageThread.cpp:85
&gt; &gt; +        WTF::sleep(10_ms);
&gt; 
&gt; Where did the `10_ms` come from?  Is there any justification as to why that
&gt; value was chosen?

Nope, the sample rate is 500ms, so this is just a small pause. I do not have a good reason for 10, other then it is small. And allows enough time for other listeners to be activated.

&gt; &gt; Source/WebCore/page/ResourceUsageThread.cpp:127
&gt; &gt; +    WTF::sleep(10_ms);
&gt; 
&gt; Should we also be waiting in the case that we already have observers?

That is what `waitUntilObservers` does. If we waited in there we will have this 10ms pause.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1501229</commentid>
    <comment_count>5</comment_count>
      <attachid>360786</attachid>
    <who name="Devin Rousso">hi</who>
    <bug_when>2019-02-01 13:09:02 -0800</bug_when>
    <thetext>Comment on attachment 360786
[PATCH] Proposed Fix

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

&gt;&gt;&gt; Source/WebCore/page/ResourceUsageThread.cpp:127
&gt;&gt;&gt; +    WTF::sleep(10_ms);
&gt;&gt; 
&gt;&gt; Should we also be waiting in the case that we already have observers?
&gt; 
&gt; That is what `waitUntilObservers` does. If we waited in there we will have this 10ms pause.

I meant more of &quot;why are we also waiting here if we&apos;re already waiting inside `waitUntilObservers`?&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1501241</commentid>
    <comment_count>6</comment_count>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-02-01 13:26:27 -0800</bug_when>
    <thetext>https://trac.webkit.org/changeset/240868/webkit</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1501261</commentid>
    <comment_count>7</comment_count>
      <attachid>360786</attachid>
    <who name="Joseph Pecoraro">joepeck</who>
    <bug_when>2019-02-01 13:45:09 -0800</bug_when>
    <thetext>Comment on attachment 360786
[PATCH] Proposed Fix

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

&gt;&gt;&gt;&gt; Source/WebCore/page/ResourceUsageThread.cpp:127
&gt;&gt;&gt;&gt; +    WTF::sleep(10_ms);
&gt;&gt;&gt; 
&gt;&gt;&gt; Should we also be waiting in the case that we already have observers?
&gt;&gt; 
&gt;&gt; That is what `waitUntilObservers` does. If we waited in there we will have this 10ms pause.
&gt; 
&gt; I meant more of &quot;why are we also waiting here if we&apos;re already waiting inside `waitUntilObservers`?&quot;

This is the first time we ever wake up the thread, and we wait here because it is created when we have a listener so it won&apos;t wait inside of `waitUntilObservers`.
If all observers unregister the thread stays alive in its while loop and will wake up when new listeners are added, those will then wait inside of `waitUntilObservers`.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>360786</attachid>
            <date>2019-01-31 14:38:37 -0800</date>
            <delta_ts>2019-02-01 11:55:09 -0800</delta_ts>
            <desc>[PATCH] Proposed Fix</desc>
            <filename>memory-1.patch</filename>
            <type>text/plain</type>
            <size>1940</size>
            <attacher name="Joseph Pecoraro">joepeck</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1NvdXJjZS9XZWJDb3JlL0NoYW5nZUxvZyBiL1NvdXJjZS9XZWJDb3JlL0No
YW5nZUxvZwppbmRleCAwODNiYjNkMGRmZC4uZTI4ZWE3Nzc3OTIgMTAwNjQ0Ci0tLSBhL1NvdXJj
ZS9XZWJDb3JlL0NoYW5nZUxvZworKysgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKQEAgLTEs
MyArMSwxOCBAQAorMjAxOS0wMS0zMSAgSm9zZXBoIFBlY29yYXJvICA8cGVjb3Jhcm9AYXBwbGUu
Y29tPgorCisgICAgICAgIFdlYiBJbnNwZWN0b3I6IE1lbW9yeSB0aW1lbGluZSBzdGFydHMgZnJv
bSB6ZXJvIHdoZW4gYm90aCBDUFUgYW5kIE1lbW9yeSB0aW1lbGluZSBhcmUgZW5hYmxlZAorICAg
ICAgICBodHRwczovL2J1Z3Mud2Via2l0Lm9yZy9zaG93X2J1Zy5jZ2k/aWQ9MTk0MTExCisgICAg
ICAgIDxyZGFyOi8vcHJvYmxlbS80NzcxNDU1NT4KKworICAgICAgICBSZXZpZXdlZCBieSBOT0JP
RFkgKE9PUFMhKS4KKworICAgICAgICAqIHBhZ2UvUmVzb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iBrZXkpCiB2b2lkIFJlc291cmNlVXNhZ2VUaHJlYWQ6OndhaXRVbnRpbE9i
c2VydmVycygpCiB7CiAgICAgTG9ja0hvbGRlciBsb2NrZXIobV9sb2NrKTsKLSAgICB3aGlsZSAo
bV9vYnNlcnZlcnMuaXNFbXB0eSgpKQorICAgIHdoaWxlIChtX29ic2VydmVycy5pc0VtcHR5KCkp
IHsKICAgICAgICAgbV9jb25kaXRpb24ud2FpdChtX2xvY2spOworCisgICAgICAgIC8vIFdhaXQg
YSBiaXQgYWZ0ZXIgd2FraW5nIHVwIGZvciB0aGUgZmlyc3QgdGltZS4KKyAgICAgICAgV1RGOjpz
bGVlcCgxMF9tcyk7CisgICAgfQogfQogCiB2b2lkIFJlc291cmNlVXNhZ2VUaHJlYWQ6Om5vdGlm
eU9ic2VydmVycyhSZXNvdXJjZVVzYWdlRGF0YSYmIGRhdGEpCkBAIC0xMTksNiArMTIzLDkgQEAg
dm9pZCBSZXNvdXJjZVVzYWdlVGhyZWFkOjpjcmVhdGVUaHJlYWRJZk5lZWRlZCgpCiAKIE5PX1JF
VFVSTiB2b2lkIFJlc291cmNlVXNhZ2VUaHJlYWQ6OnRocmVhZEJvZHkoKQogeworICAgIC8vIFdh
aXQgYSBiaXQgYWZ0ZXIgd2FraW5nIHVwIGZvciB0aGUgZmlyc3QgdGltZS4KKyAgICBXVEY6OnNs
ZWVwKDEwX21zKTsKKyAgICAKICAgICB3aGlsZSAodHJ1ZSkgewogICAgICAgICAvLyBPbmx5IGRv
IHdvcmsgaWYgd2UgaGF2ZSBvYnNlcnZlcnMuCiAgICAgICAgIHdhaXRVbnRpbE9ic2VydmVycygp
Owo=
</data>
<flag name="review"
          id="377486"
          type_id="1"
          status="+"
          setter="hi"
    />
          </attachment>
      

    </bug>

</bugzilla>