-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Report A and script loading to resource timing #7180
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
Conversation
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.
Non-authoritative LGTM % nit
3ad0e7f
to
84873cb
Compare
@domenic, review when possible please? |
source
Outdated
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> given | ||
<span data-x="concept-response">response</span> <var>res</var> set to | ||
<span>finalize and report timing</span> with <var>res</var>, the | ||
<span>current global object</span>, and "a".</p></li> |
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.
"<code data-x="">a</code>"
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.
Fixed
source
Outdated
@@ -24226,7 +24227,11 @@ document.body.appendChild(wbr);</code></pre> | |||
</dl> | |||
</li> | |||
|
|||
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>.</p></li> | |||
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>, with | |||
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> given |
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 ties into whatwg/fetch#1382 ... if someone sends a long trickle body, do we really want to wait for it before finalizing and reporting timing? What do browsers do? That issue suggests maybe they terminate the body early?
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.
Chrome does something equivalent to processResponseEndOfBody
. I'll revise.
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.
Fixed
source
Outdated
|
||
<ol> | ||
<li><p><span>Finalize and report timing</span> with <var>response</var>, the | ||
<span>current global object</span> and "script".</p></li> |
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.
"<code data-x="">script</code>"
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.
Fixed
source
Outdated
@@ -91620,7 +91637,9 @@ document.querySelector("button").addEventListener("click", bound); | |||
<span>JavaScript MIME type</span>,</p> | |||
</ul> | |||
|
|||
<p>then asynchronously complete this algorithm with null, and return.</p> | |||
<p>then <span>finalize and report timing</span> with <var>response</var>, the |
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 we should consolidate this into the previous step now. Something like:
If any of the following conditions are met:
- x;
- y; or
- z and w
then:
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.
Fixed
source
Outdated
@@ -91635,6 +91654,9 @@ document.querySelector("button").addEventListener("click", bound); | |||
data-x="concept-response-url">url</span>, and the <span>default classic script fetch | |||
options</span>.</p></li> | |||
|
|||
<li><p><span>Finalize and report timing</span> with <var>response</var>, the | |||
<span>current global object</span> and "script".</p></li> |
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.
Is it correct that this happens after parsing? I could imagine parsing taking a few milliseconds...
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.
Changed to make it happen prior to parsing
source
Outdated
|
||
<p class="note"><var>response</var> is always <span>CORS-same-origin</span>.</p> | ||
</li> | ||
|
||
<li><p><span>Finalize and report timing</span> with <var>response</var>, the | ||
<span>current global object</span> and "script".</p></li> |
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.
Here you report timing before parsing happens. That is cleaner since then you don't have duplicate "finalize and report timing with response, the current global object, and script".
source
Outdated
<i data-x="processResponseConsumeBody">processResponseConsumeBody</i> given | ||
<span data-x="concept-response">response</span> <var>res</var> set to | ||
<span>finalize and report timing</span> with <var>res</var>, the | ||
<span>current global object</span>, and "a".</p></li> |
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.
There is no "current global object" in most of these algorithms. You need to use the <span data-x="concept-settings-object-global">global object</span>
of one of the various settings objects passed into each algorithm. (I'm not sure which one in each case...)
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.
Fixed
0b529b6
to
e51e434
Compare
source
Outdated
<i data-x="processResponseEndOfBody">processResponseEndOfBody</i> given | ||
<span data-x="concept-response">response</span> <var>res</var> set to | ||
<span>finalize and report timing</span> with <var>res</var>, <var>global</var>, and | ||
"<code data-x="">ping</code>".</p></li> |
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.
OK, so to be clear, if the body is not fully downloaded (because the server trickles it, for example) by the time the page unloads due to the link navigation, no resource timing entry will be created. Is that correct? Are there tests for that case?
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.
By the time the page unloads you can't test whether an RT entry is created.
But RT entry is created when for example you have a link with a target
attribute. I'll make sure tests cover this.
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.
Right. I was thinking that maybe browsers sent the resource timing when the response headers came in, not when the whole body did. It sounds like that is not the case.
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.
Yea, I double-checked this.
source
Outdated
<li><p>Let <var>global</var> be the | ||
<span data-x="concept-settings-object-global">global object</span> of the | ||
<span>environment settings object</span> of the <code>Document</code> containing the | ||
<span>hyperlink</span>. |
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 Document containing the hyperlink" is not defined (although I see that is used in preexisting text); nor is "the environment settings object of [a Document]".
It'd be best to factor this out as follows:
- Let client be the element's node document's relevant settings object.
- Later, passing client's global object to "finalize and report timing".
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 called it settingsObject
rather than client
, seemed more explicit. Otherwise fixed.
source
Outdated
@@ -91917,7 +91930,18 @@ document.querySelector("button").addEventListener("click", bound); | |||
<span>ok status</span>,</p></li> | |||
</ul> | |||
|
|||
<p>then asynchronously complete this algorithm with null, and return.</p> | |||
<p>then:</p> |
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 did not get fixed: #7180 (comment)
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.
OK, maybe I misunderstood that original comment. Will reread
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 refactored that bit, hope it's satisfactory.
source
Outdated
algorithm, and run the remaining steps as part of the fetch's <span>process response</span> for | ||
the <span data-x="concept-response">response</span> <var>response</var>.</p> | ||
algorithm, and run the remaining steps as part of the fetch's | ||
<i>processResponseConsumeBody</i> for <span data-x="concept-response">response</span> |
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.
Please make this cross-link to the definition in Fetch, with the appropriate data-x attribute on the <i>
.
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.
Fixed
source
Outdated
|
||
<p class="note"><var>response</var> is always <span>CORS-same-origin</span>.</p> | ||
</li> | ||
|
||
<li><p><span>Finalize and report timing</span> with <var>response</var>, the | ||
<span>current global object</span> and "script".</p></li> |
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.
Missing code around script
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.
Fixed
a3322fb
to
062c28b
Compare
@domenic, re-review? :) |
Sorry, on my near-term to-do list but I got to the end of another the day without having made the time. Tomorrow for sure! |
source
Outdated
<var>response</var>, <var>fetch client settings object</var>'s | ||
<span data-x="concept-settings-object-global">global object</span>, and | ||
"<code data-x="">other</code>", asynchronously complete this algorithm with | ||
null, and return.</p> |
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.
Sorry, this is still not great.
To be clear, the structure in your PR right now is:
- If either of the following conditions are met:
- x; or
- y
then:
- Finalize and report...
- Asynchronously complete with null
- Return.
- If z and w, then: finalize and report..., asynchronously complete with null, and return.
Can you see how this is bad? I am proposing instead we do the following:
- If any of the following conditions are met:
- x;
- y; or
- z and w
then:
- Finalize and report...
- Asynchronously complete with null
- Return.
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.
Ah I see what you mean now. It was entirely unclear to me what you meant in the original comment.
source
Outdated
<li><p>Let <var>source text</var> be the result of <span data-x="UTF-8 decode">UTF-8 | ||
<li><p><span>Finalize and report timing</span> with <var>response</var>, | ||
<var>fetch client settings object</var>'s | ||
<span data-x="concept-settings-object-global">global object</span> and |
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.
<span data-x="concept-settings-object-global">global object</span> and | |
<span data-x="concept-settings-object-global">global object</span>, and |
source
Outdated
<span data-x="concept-settings-object-global">global object</span> and | ||
"<code data-x="">other</code>".</p></li> | ||
|
||
<li><p>Let <var>source text</var> be the result of <span data-x="UTF-8 decode">UTF-8 |
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.
Indentation changed here, but it should not.
Starting with two elements that perform a full download, and have decent HTML/fetch integration. A element: report resource timing for download & ping Script: report resource timing for importing, classic and worker. Reporting is *always* done before load/error events are fired, so that those events could get access to the new entry.
- Use proper global object from env settings - Report before parsing - Change callback for ping
062c28b
to
75f9b84
Compare
@domenic: I did a major refactor to use |
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 works pretty well. At some point we should clean the surrounding code in the script-fetching algorithms up to use the second parameter to processResponseConsumeBody, instead of what it currently does of UTF-8 decoding response's body. But that is a preexisting problem and I'm happy to tackle it separately, now that you've factored this PR to not touch that part of things.
Tests look pretty comprehensive so I think this is ready to merge. I'll do so tomorrow unless anyone has thoughts.
Starting with two elements that perform a full download, and have decent
HTML/fetch integration. Finalize and report resource timing once the response body is fully read or there is a network error,
and before any load/error events are fired.
Resolves part of #6542
A element: report resource timing for download & ping
Script: report resource timing for importing, classic and worker.
Reporting is always done before load/error events are fired, so that
those events could get access to the new entry.
[x] At least two implementers are interested (and none opposed):
This is already implemented in Chrome, Safari and Firefox, and was previously spec'ed as part of resource timing.
Some of the specific discrepancies will be handled as part of WPT.
[x] New tests for previously unspecified scenarios: web-platform-tests/wpt#32513
[X] Implementation bugs are filed:
Chrome: https://bugs.chromium.org/p/chromium/issues/detail?id=1290356
Firefox: No currently known bugs
Safari: No currently known bugs
(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/links.html ( diff )
/webappapis.html ( diff )
/infrastructure.html ( diff )
/links.html ( diff )
/webappapis.html ( diff )