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.
<rdar://problem/47714555>
Created attachment 360786 [details] [PATCH] Proposed Fix
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?
(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 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`?"
https://trac.webkit.org/changeset/240868/webkit
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`.