-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Lazyload iframes #5579
Lazyload iframes #5579
Conversation
Invoke will lazy load steps from otherwise steps
88cb1ce
to
aa59e38
Compare
As specified it doesn't account for The other problem I foresee here is that navigation obtains certain state at which point we run into nondeterminism in the sense that it matters when the user scrolls the page. This already exists to some extent, e.g., with the cc @clelland |
@domfarolino asked me to look at this to get a second set of eyes on the concern
I tried to get an exhaustive list of all the mutable state that affects navigation. They are:
Given how non-uniformly these are handled right now, my intuition is that the cleanest thing to do is to proceed as this PR does, by making minimal changes to the "navigate" algorithm and instead doing the deferral in the "otherwise steps". That leaves us better equipped to clean these up in the manner suggested in #4926 later. That is, if we go mucking around inside the navigation algorithm (by e.g. moving the deferral until right before "process a navigate fetch"), that will make future refactoring into an up-front policy-container harder. (Or at the very least we'd have to move the deferral back up into the otherwise steps.) And we'd end up having to duplicate a lot of the checks in "navigate" after the deferral runs its course, since they are important for security. So if we go with this PR as-is, this would give us the following behavior for images vs. iframes. Here I used "loading-started" to refer to the beginning of the relevant loading algorithm (usually right after the element gets inserted into the document), and "loading-committed" to refer to the point after which we're about to fetch from the network (e.g., once the user has scrolled down enough).
This seems like an acceptable intermediate state for me. If I were to change anything, it would be to find out if we can uniformize the behavior of Now, what is the ultimate desired state? We should probably discuss that in another issue, perhaps #4926 or perhaps a dedicated one. #4926 gestures at moving everything into "snapshotted at loading-started". But getting there will be pretty difficult, especially given the extensive dependency on browsing contexts in CSP and sandboxing. And the discussion might impact other fetches, such as |
Thanks a ton for the detailed feedback @domenic! I have a couple of corrections:
I'll go ahead and edit your comment, but actually the image loading process is interesting: We arguably "snapshot" every property of the request before load-committed, but both Given this, I think uniformizing these attributes would require introducing something like a relevant mutations equivalent for the iframe element, which would basically involve:
But yeah I'm fine with that being done separately, if it is desirable. Given all this, I think this is ready for review! |
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 mostly an editorial review. I haven't reviewed the tests or tried to dig deep, yet. I'll be able to review in more detail later this month.
Requesting review from @domenic as well given his feedback, and the current state of the PR. |
That isn't quite true, right? Because of the image cache, which is not keyed by |
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.
LGTM with nit and my comment about potentially increasing the clarity for both img and iframe about "the rest of this algorithm".
The main unresolved question I think we have is should |
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.
Changes LGTM. I think the other way would be slightly nicer but I'm happy to leave that for a future refactoring.
Since <iframe srcdoc>
s are all inline, I don't think lazy-loading them is particularly helpful---at least, it doesn't save bandwidth---but it's hard for me to say. If it has no effect, then we should make it a document conformance error to use the loading attribute when the srcdoc attribute is present.
Does anyone else have opinions or insights?
I think it's a little more complicated. A |
So I think this was discussed a bit in IRC, but it'd be good to record the conclusion in the thread. As I see it we have three options:
What's the plan? |
I believe the plan is (3), to support srcdoc in this PR and test it. I'll try and do at least one of those today or tomorrow. |
The latest commit(s) add I also fixed what I consider a small bug that I added in the otherwise frame steps. When we run 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.
This looks sensible to me :)
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.
Can someone sanity check me here? I want to make sure that
So I think we're good. Buttttt, this brings me to a difference I spotted between iframe and image lazy loading. For image lazy loading, even if the request is resumed before the window load event is fired, the request doesn't delay the window load event. This is due to #updating-the-image-data-step21. However for iframes, even if the load is resumed before the containing document's window load event is fired, then eventually we'll end up in the Navigation algorithm, and the nested browsing context will be put into the I think one non-invasive way to fix this would be to keep some state that is persistent per-iframe-request that basically says
...to say...
This gives us a per-request state independent of the Either way, we'll need a test like so:
|
This PR augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. I am TBR'ing this because sclittle@ already reviewed this at #24361, but doesn't have the permissions to submit an "authoritative" review over there. TBR=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. I am TBR'ing this because sclittle@ already reviewed this at #24361, but doesn't have the permissions to submit an "authoritative" review over there. TBR=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. I am TBR'ing this because sclittle@ already reviewed this at #24361, but doesn't have the permissions to submit an "authoritative" review over there. TBR=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/master@{#784331}
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/master@{#784331}
This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28
This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381}
This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381}
This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381}
…, a=testonly Automatic update from web-platform-tests Augment iframe lazyload tests for srcdoc This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/master@{#784331} -- wpt-commits: 36c3b7dbdcb6f955ef2d64aad14efb13c80e4c67 wpt-pr: 24407
…t, a=testonly Automatic update from web-platform-tests Add iframe lazy load event semantics test This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381} -- wpt-commits: 54eb49dcb97c59910f8b6d9830d73ea11366b7e5 wpt-pr: 24410
…, a=testonly Automatic update from web-platform-tests Augment iframe lazyload tests for srcdoc This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/master@{#784331} -- wpt-commits: 36c3b7dbdcb6f955ef2d64aad14efb13c80e4c67 wpt-pr: 24407
…t, a=testonly Automatic update from web-platform-tests Add iframe lazy load event semantics test This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381} -- wpt-commits: 54eb49dcb97c59910f8b6d9830d73ea11366b7e5 wpt-pr: 24410
Alright, this has accumulated quite a set of approvals by now. I'll merge this tomorrow unless anyone else wants to take a final look. |
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.
Looks sane to me.
This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#784331} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 2d795fa0288e09f222f46ee09e50a74909389ec5
This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#784381} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 6884ac62d2eb97e24f78e75dc1c4542db7982d28
…, a=testonly Automatic update from web-platform-tests Augment iframe lazyload tests for srcdoc This CL augments the existing iframe lazyload test for srcdoc lazyload support. Chrome currently does not implement this. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101170 Change-Id: I5c5790c5d2eca3efbb01c5470e2267f2265858f6 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2276624 Reviewed-by: Scott Little <sclittle@chromium.org> Commit-Queue: Dominic Farolino <dom@chromium.org> Cr-Commit-Position: refs/heads/master@{#784331} -- wpt-commits: 36c3b7dbdcb6f955ef2d64aad14efb13c80e4c67 wpt-pr: 24407
…t, a=testonly Automatic update from web-platform-tests Add iframe lazy load event semantics test This CL adds WPTs asserting that in-viewport loading=lazy iframes do not block the outer window load event. The test accompanies the spec change made at: whatwg/html#5579. R=sclittle@chromium.org Bug: 1101175 Change-Id: I5e337f6c87c8198e8e5bae5a32263698fb3daf28 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277384 Commit-Queue: Dominic Farolino <dom@chromium.org> Reviewed-by: Scott Little <sclittle@chromium.org> Cr-Commit-Position: refs/heads/master@{#784381} -- wpt-commits: 54eb49dcb97c59910f8b6d9830d73ea11366b7e5 wpt-pr: 24410
Fixes #5496.
loading=lazy
iframes do not load)loading=lazy
iframes can be lazy loaded multiple times, and that a document in an iframe isn't unloaded until the second time theready to be lazy loaded
flag is loadedloading=eager
and then immediately removing the attribute still continues the load (we need this for images too)loading=eager
on a deferred iframe correctly sets theready to be lazy loaded flag
and continues the loadAside: One thing I noticed about #5510 is that I think it didn't fully fix #5236. I think it's still weird that we're waiting in parallel for the
ready to be lazy loaded
bool to be mutated on the main thread, and then we queue a task from in-parallel to continue. IMO one of the big wins of using an IntersectionObserver is that we can use the callback to just synchronously finish the loading right from there. I'll start another thread with my latest proposed design to fix this, but for now, the iframe spec behaves similar to images./embedded-content.html ( diff )
/iframe-embed-object.html ( diff )
/images.html ( diff )
/indices.html ( diff )
/urls-and-fetching.html ( diff )