Bug 194111 - Web Inspector: Memory timeline starts from zero when both CPU and Memory timeline are enabled
Summary: Web Inspector: Memory timeline starts from zero when both CPU and Memory time...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Inspector (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-31 13:44 PST by Joseph Pecoraro
Modified: 2019-02-01 13:45 PST (History)
4 users (show)

See Also:


Attachments
[PATCH] Proposed Fix (1.89 KB, patch)
2019-01-31 14:38 PST, Joseph Pecoraro
hi: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2019-01-31 13:44:35 PST
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
  => 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.
Comment 1 Radar WebKit Bug Importer 2019-01-31 13:44:54 PST
<rdar://problem/47714555>
Comment 2 Joseph Pecoraro 2019-01-31 14:38:37 PST
Created attachment 360786 [details]
[PATCH] Proposed Fix
Comment 3 Devin Rousso 2019-01-31 16:43:48 PST
Comment on attachment 360786 [details]
[PATCH] Proposed Fix

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

rs=me

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

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

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

Should we also be waiting in the case that we already have observers?
Comment 4 Joseph Pecoraro 2019-02-01 11:54:57 PST
(In reply to Devin Rousso from comment #3)
> Comment on attachment 360786 [details]
> [PATCH] Proposed Fix
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=360786&action=review
> 
> rs=me
> 
> > Source/WebCore/page/ResourceUsageThread.cpp:85
> > +        WTF::sleep(10_ms);
> 
> Where did the `10_ms` come from?  Is there any justification as to why that
> 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.

> > Source/WebCore/page/ResourceUsageThread.cpp:127
> > +    WTF::sleep(10_ms);
> 
> 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.
Comment 5 Devin Rousso 2019-02-01 13:09:02 PST
Comment on attachment 360786 [details]
[PATCH] Proposed Fix

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

>>> Source/WebCore/page/ResourceUsageThread.cpp:127
>>> +    WTF::sleep(10_ms);
>> 
>> 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.

I meant more of "why are we also waiting here if we're already waiting inside `waitUntilObservers`?"
Comment 6 Joseph Pecoraro 2019-02-01 13:26:27 PST
https://trac.webkit.org/changeset/240868/webkit
Comment 7 Joseph Pecoraro 2019-02-01 13:45:09 PST
Comment on attachment 360786 [details]
[PATCH] Proposed Fix

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

>>>> Source/WebCore/page/ResourceUsageThread.cpp:127
>>>> +    WTF::sleep(10_ms);
>>> 
>>> 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.
> 
> I meant more of "why are we also waiting here if we're already waiting inside `waitUntilObservers`?"

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'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`.