-
Notifications
You must be signed in to change notification settings - Fork 312
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
Maintain timing for worker start/ready, for navigation requests. #1575
Conversation
Sorry for the delay, I've been on leave. I'll try to get to this this week, or early next week. |
Sorry, I missed I was tagged here. I generally defer to the editors to do spec reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, and sorry for the delay reviewing. @mfalken and I took a look.
It isn't clear to me how these values will be read. I'm slightly worried that there's one service worker, therefore one "start time" and one "ready time", but many requests. It feels like "start time" and "ready time" might be overwritten by another request in a race.
Maybe these values should instead be associated with the response, since the timing is from the perspective of the request/response. But I'm just guessing, because I'm not sure how these values will be used.
For instance, if the service worker was started a year ago, and never closed for some reason, should "worker start" be the time a year ago, or should it be the time a given request decided it needed a service worker?
docs/index.bs
Outdated
@@ -2971,6 +2975,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe | |||
1. Let |preloadResponse| be a new [=promise=]. | |||
1. Let |workerRealm| be null. | |||
1. Let |eventHandled| be null. | |||
1. Let |crossOriginIsolatedCapability| be |request|'s [=request/client=]'s [=environment settings object/cross-origin isolated capability=]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has someone familiar with isolation looked at this? Two timings are taken, once from "in parallel", and another from the service worker thread. Neither of these are the request's client, so does the request's client's cross-origin isolated capability apply here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's how things are done in FETCH. Not sure if it applies to service workers. in the same way. @annevk ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting as there might be a mismatch between the service worker agent and the requesting agent. I suspect we have to consult both and only if they are both true you would get the high-resolution time. Does that make sense?
That might be a change from what is implemented today as that probably only considers the requesting agent.
(Fetch uses the requesting agent exclusively as it doesn't create any agents of its own.)
docs/index.bs
Outdated
@@ -3020,6 +3025,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe | |||
1. If |shouldSoftUpdate| is true, then [=in parallel=] run the [=Soft Update=] algorithm with |registration|. | |||
1. Return null. | |||
1. If |activeWorker|'s <a>state</a> is "`activating`", wait for |activeWorker|'s <a>state</a> to become "`activated`". | |||
1. Let |workerStartTime| be the [=coarsened shared current time=] given <var>crossOriginIsolatedCapability</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous step (If |activeWorker|'s <a>state</a> is "activating"
) probably should be included in this measurement, since we've decided we need a service worker, but it might not be ready. If the site is seeing long delays due to activation delays, that feels important.
Yea, I thought it would be the time the request decided it needed a service worker if the worker was already running. |
OK, I will change it to mean the "first" start/ready time. These values are only meant for Navigation Timing, I'll prepare a Navigation Timing PR that reads them to make it clearer. (they would have inter-dependencies so this one would have to go in first).
The service worker's start time would be a year ago, but Navigation Timing would expose the later time between that time and the time FETCH has handed control over to the service worker. |
I've refactored the PR, I agree that it makes much more sense to associate the info with the response rather than with the worker.
There are probably more ways to accomplish the same results, I went with the way that made the most sense to me but I'm open to refactor given an alternative approach. |
docs/index.bs
Outdated
|
||
Service workers mark certain points in times, that are later exposed by the {{PerformanceNavigationTiming|navigation timing}} API. | ||
|
||
A [=/response=] has an associated null or [=service worker timing info=] <dfn export for=response>service worker timing</dfn>, initially set to null. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we defined this in Fetch and SW just does the marking. Mainly to keep response defined in a single place.
Is it correct that this information gets lost if a network error is returned instead at some point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we defined this in Fetch and SW just does the marking. Mainly to keep response defined in a single place.
OK. I was trying to make it so that FETCH doesn't have to be modified every time we add a new service-worker metric. Should the struct live in FETCH as well?
Is it correct that this information gets lost if a network error is returned instead at some point?
This is only exposed through Navigation Timing. So, if there's a network error, the document won't be loaded and these values would be meaningless. In other words, correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's okay to keep the struct here to make that easier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jakearchibald I want to make sure we're OK with how this whole process works, and then I'll publish:
- A SW PR that defines the new struct
- A FETCH PR that associates the struct with a response and adds arguments to the SW FETCH call
- The marking part of the SW PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes, but generally LGTM
docs/index.bs
Outdated
@@ -2958,6 +2974,7 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe | |||
|
|||
: Input | |||
:: |request|, a [=/request=] | |||
:: |crossOriginIsolatedCapability|, a boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It isn't clear to me which client this isolation refers to. Maybe it should just be useHighResPerformanceTimers
or something which makes the scope of its usage clear?
docs/index.bs
Outdated
@@ -193,15 +193,31 @@ spec: webappsec-referrer-policy; urlPrefix: https://w3c.github.io/webappsec-refe | |||
* Detects abnormal operation: such as infinite loops and tasks exceeding imposed time limits (if any) while handling the events. | |||
</section> | |||
|
|||
<section> | |||
<section> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unintentional change?
to report worker-specific timing information to Navigation Timing. In preparation for w3c#1575
to report worker-specific timing information to Navigation Timing. In preparation for #1575
Give me a nudge when this is ready to go |
Thanks, will do! first I need to wait for the refs to apply and post a FETCH PR. |
In preparation for w3c/ServiceWorker#1575 and w3c/navigation-timing#143 This will allow exposing the service worker timing as part of the Navigation Timing API.
The timing when worker is started or ready are web-accessible via the navigation timing API (https://w3c.github.io/navigation-timing/). `workerStart` is specified to be the time when the service worker is run. In Chromium and Gecko, `worker ready time` (exposed as `fetchStart`) is set to the right before the time when the Fetch event can be dispatched for the newly created worker. In preparation for w3c/navigation-timing#136
Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
Co-authored-by: Jake Archibald <jaffathecake@gmail.com>
Temporarily remove response association, as that moves to FETCH.
Nudge @jakearchibald :) |
Service Workers now expose a "service worker timing info" that is associated with a request. HTML should pass it to Navigation Timing together with the other info. See also w3c/navigation-timing#143 and w3c/ServiceWorker#1575
What about #1575 (comment)? |
Fixed in new revision. |
Thank you @noamr! |
Service Workers now expose a "service worker timing info" that is associated with a request. HTML should pass it to Navigation Timing together with the other info. See also w3c/navigation-timing#143 and w3c/ServiceWorker#1575
Amend the parameters passed when creating the navigation timing info entry to include the service worker timing info. Also, pass 0 for redirectCount When cross-origin redirects occurred as part of the navigation. See also w3c/navigation-timing#143 and w3c/ServiceWorker#1575.
Amend the parameters passed when creating the navigation timing info entry to include the service worker timing info. Also, pass 0 for redirectCount When cross-origin redirects occurred as part of the navigation. See also w3c/navigation-timing#143 and w3c/ServiceWorker#1575.
The timing when worker is started or ready are web-accessible via
the navigation timing API (https://w3c.github.io/navigation-timing/).
workerStart
is specified to be the time when the service worker is run.In Chromium and Gecko,
worker ready time
(exposed asfetchStart
)is set to the right before the time when the Fetch event can be
dispatched for the newly created worker.
In preparation for w3c/navigation-timing#136
Preview | Diff