-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spec what requestStart, responseStart, and responseEnd should represent when service worker is involved #119
Comments
@mattto Do you have any input here? I'd like to be compatible if we can, but these other values seem under specified. |
For subresource requests chrome seems to generate Is there any guaranteed ordering between these two? |
Actually, I decided to bring the |
Yes I've seen some strange behavior from Chrome. I think our workerStart is created when the renderer process (i.e., web content process) has begun starting up the worker thread, but service worker startup actually starts before that in the browser process. I wouldn't be surprised if there are things to improve here both spec and implementation wise. I wrote a bit about this before at https://groups.google.com/a/chromium.org/d/msg/blink-dev/ck9M6Ev21lo/oj8kK098CAAJ |
Maybe we can quickly sketch "what does each timing value mean in each browser" at TPAC. Even if its not spec'd it would be nice to put it in this issue. Should I leave the "workerStart >= fetchStart" in the test for now? Note, I am expanding the test with:
|
Sounds good to discuss at TPAC (but I'd have to prepare to be able to share accurate information). Maybe better to focus on what the timing values should mean. Makes sense to me to assert fetchStart < workerStart. cc/ @igrigorik @spanicker |
I mean yea workerStart >= fetchStart makes sense to me. |
Honestly I don't really know what "fetchStart" means for a synthesized response. I'm making our values conform to this, but I don't know if they make sense. |
I guess it would be useful to know what sites interpret these values to mean today. @n8schloss do you have any insight here? |
Just thinking about it a bit I would recommend the following:
And I guess Any thoughts? |
nod.. I think those make sense.
The delta between workerStart and fetchStart is meant to capture the worker startup time. They are not the same, unless worker is already ready or there is no worker to start... /cc @toddreifsteck |
That is not what the spec says for step 1.2 here: https://w3c.github.io/resource-timing/#dom-performanceresourcetiming-workerstart "Immediately before the user agent runs the worker" should be before the browser starts its thread. Assuming "run the worker" refers to the current "run service worker" algorithm here: https://w3c.github.io/ServiceWorker/#run-service-worker-algorithm The thread isn't created until step 4 there. |
I just implemented workerStart based on the interpretation in #119 (comment). If this is wrong, it would be great to get clarification. @mattto, what does chrome do here? |
I think I misunderstood #119 (comment). I think my problem is I don't understand what |
I think we really need the spec aligned with fetch spec to clarify service worker behavior with these values. In the meantime I will move |
I think Chome will have different behavior depending on whether the service worker provided a response or fell back to network. When it falls back to network we don't seem to set workerStart. It's a bug. We seem to try to set workerStart to the time we decide a service worker is needed, and fetchStart to the time right before we start dispatching the fetch event to the running worker (fetchStart is set in the browser/parent process, not in the renderer/content process or worker thread). So I'm not sure why in some cases fetchStart happens before workerStart as the output in the original comment shows. |
Values in the initial comment here may have been from a redirect leading to an intercepted request. I can't remember, unfortunately. |
I took a closer look at how Chrome implements these attributes. Here is summary:
I think that Other things we may want to clarify are:
|
|
ServiceWorkerNavigationLoader is responsible for setting up LoadTimingInfo which are used to create web-exposed PerformanceResourceTiming. Specifically, the field |send_start| in LoadTimingInfo is populated as `requestStart` in PerformanceResourceTiming. The resource timing spec[1] doesn't state explicitly but according to a spec discussion[2], following ordering would be reasonable: workerStart <= fetchStart <= requestStart Before this CL, ServiceWorkerNavigationLoader recorded `requestStart` before starting a service worker, at the same time `workerStart` is recorded. This doesn't seem a good timing because `requestStart` would be less than `fetchStart`, which is recorded after the service worker is started. This CL moves the timing to record |send_start| (and corresponding |send_end|) to the time the service worker is started. Note that web-exposed `fetchStart` still doesn't follow the above ordering even after this CL, as we have a special case code for `fetchStart` in navigation. A follow-up CL will address `fetchStart` case. The wpt service-workers/service-worker/navigation-timing.https.html should cover this change. [1] https://w3c.github.io/resource-timing/#sec-performanceresourcetiming [2] w3c/resource-timing#119 Bug: 782958 Change-Id: I339d41d8c93a2cbcd053d4348d8e0f51b1134925 Reviewed-on: https://chromium-review.googlesource.com/1212423 Reviewed-by: Kinuko Yasuda <[email protected]> Reviewed-by: Makoto Shimazu <[email protected]> Commit-Queue: Kenichi Ishibashi <[email protected]> Cr-Commit-Position: refs/heads/master@{#589458}
As the workerStart nuances seem to be covered in #118, it seems safe to bump this to L3, when we'll actually define Fetch intergration. |
👍 |
Let me revive this issue to confirm my understanding of the conclusion of this discussion. Here's my understanding:
In short, the conclusion is mostly #119 (comment) but Is this correct? |
In Chrome the milestones are like this:
Based on this thread, perhaps these milestones may be worth considering:
The current text spec seems rather different:
Do the milestones [A], [D], [F] make sense for workerStart, fetchStart, requestStart? A complication is redirects, but maybe we can just use the final request for all of workerStart, fetchStart, requestStart. |
This means |
Yeah, I think we should avoid that, so I agree with keeping It feels like the spec is trying to say
To me, it seems like it's saying the source of the data has been selected, but that source hasn't yet been queried. But the existence of
If folks just want to capture worker startup time, then yeah we'd need something like |
^^ @nicjansma |
In the case where a page is controlled by a SW (with a registered fetch event handler),
Can one infer the SW start up time by computing
In other words, is the time immediately before fetch event is fired the same as |
(belated) Notes from Service Worker WG meeting on Nov 20:
|
I think this is now covered explicitly in the FETCH & SW specs and also in WPT. |
I'm trying to improve the PerformanceRequestTiming support in firefox when a request is intercepted by a service worker. I've implemented
workerStart
, but its a bit unclear whatrequestStart
,responseStart
, andresponseEnd
mean in this context.Looking at the output from chrome it seems like these are being set:
Here
requestStart
is slightly afterworkerStart
. Is this whenrespondWith()
was called?The
responseStart
is a few milliseconds later. Does this measure when therespondWith()
promise resolves?I assume
responseEnd
is when the synthesized body is complete.Also, the WPT test here:
https://github.com/w3c/web-platform-tests/blob/master/service-workers/service-worker/resource-timing.https.html#L15
Wants
workerStart
to occur beforefetchStart
, but that is not what chrome is doing for this request. Also, this requirement was a bit awkward to implement in firefox. We triggerworkerStart
after we create our network channel, so its more natural forfetchStart
to occur first. I plan to relax this requirement in the WPT test.The text was updated successfully, but these errors were encountered: