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
Request's associated element #912
Comments
Is this something that would need to be passed through a service worker that does Also, how would this interact with the element lifecycle? For example, if the element is removed and discarded during the fetch, will the fetch keep it alive? |
At least for the usecase we have in mind, that's not necessary.
Ideally we'd want to keep around a weak pointer to that element, so that a pending fetch, or a buffered ElementTiming entry won't keep it alive. Not sure what's the equivalent spec concept. |
How long do you need the element reference for? Could this be something where we ensure everyone invokes "fetch" from the "main thread" and before "fetch" returns (and goes in parallel) it's able to drop the reference? I guess with the |
We'd need the element's reference for longer than the lifetime of the fetch, as the reported entries are likely to be looked at after that. That is at least true if we want to maintain a link from the entries themselves to the element in question (which would be the most ergonomic solution, assuming we can pull it off). |
It doesn't seem like Fetch would need to hold a reference for that. In its "main thread" section Fetch could create an entry and pass on the relevant information. And then at various points update the entry. Is the element needed for the updates? |
Yeah, Fetch would just need to pass the reference to the entry, not necessary keep it beyond that. Regarding the need for the element during updates, I don't think that's needed. @npm1 - thoughts? |
Yea that should be fine. Besides the Element, the other information we need related to the request is the 'responseEnd' (from ResourceTiming...). |
Implementation-wise this could be problematic because multiple elements can share one fetch request - with cache, for example. I guess we would have the same problem in the spec world. cc @hiroshige-g |
If the caches are defined in terms of Fetch and this were defined in terms of Fetch, all of that would fall out "naturally". To the extent things are not defined there would indeed be challenges. |
https://html.spec.whatwg.org/multipage/images.html#the-list-of-available-images is a cache defined outside of the fetch spec. |
In general, I'd like to avoid adding dependencies from Fetch spec to specific elements, because Chromium is separating fetch implementation from HTML/DOM implementation (different processes, different directories, etc.). I'm afraid that Also, I feel there might be better places (outside Fetch spec) to be associated with elements.
But image request and fetch request are different. For example, in the case of
there would be two image requests (one for each |
@hiroshige-g the process split makes sense and I think other implementations are moving in similar directions. However, I think it's okay for Fetch to cover both sides. Before we go "in parallel" we have access to state like this, after we go "in parallel" such state is no longer present. (Ideally CSS uses a similar image loading code path. I'm pretty sure it does in implementations, but the CSS specifications are not updated with this kind of information.) |
Is this enforced in the spec? (e.g. if we add |
We could explicitly set it to null and then assert it's null after passing the boundary and I agree that we'd never want to change that. |
Element Timing has a concept of a Request's associated element, which is currently not well defined in terms of Fetch. I'd like to better define that, by being able to pass along the associated element when fetching an image at updating the image data.
Any objections to take that approach? Better ways to achieve the same?
/cc @annevk @domenic @npm1
The text was updated successfully, but these errors were encountered: