Bug 215566 - Add setting for lazy iframe loading
Summary: Add setting for lazy iframe loading
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks: 196698
  Show dependency treegraph
 
Reported: 2020-08-17 07:03 PDT by Rob Buis
Modified: 2020-08-25 09:44 PDT (History)
5 users (show)

See Also:


Attachments
Patch (5.13 KB, patch)
2020-08-17 07:52 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (11.03 KB, patch)
2020-08-17 12:33 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (9.53 KB, patch)
2020-08-17 12:34 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (9.26 KB, patch)
2020-08-19 05:24 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (2.83 KB, patch)
2020-08-25 05:45 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (2.83 KB, patch)
2020-08-25 08:45 PDT, Rob Buis
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Buis 2020-08-17 07:03:52 PDT
Add runtime flag for lazy iframe loading
Comment 1 Rob Buis 2020-08-17 07:52:12 PDT
Created attachment 406716 [details]
Patch
Comment 2 Sam Weinig 2020-08-17 10:36:23 PDT
Comment on attachment 406716 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406716&action=review

> Source/WebKit/Shared/WebPreferences.yaml:2038
> +  webcoreBinding: RuntimeEnabledFeatures

What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.
Comment 3 Rob Buis 2020-08-17 11:01:01 PDT
Comment on attachment 406716 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406716&action=review

>> Source/WebKit/Shared/WebPreferences.yaml:2038
>> +  webcoreBinding: RuntimeEnabledFeatures
> 
> What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.

This will be used though to enable the loading attribute in HTMLIFrameElement.idl, AFAIK there is not a way to make that work using Settings.
Comment 4 Sam Weinig 2020-08-17 11:16:15 PDT
(In reply to Rob Buis from comment #3)
> Comment on attachment 406716 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406716&action=review
> 
> >> Source/WebKit/Shared/WebPreferences.yaml:2038
> >> +  webcoreBinding: RuntimeEnabledFeatures
> > 
> > What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.
> 
> This will be used though to enable the loading attribute in
> HTMLIFrameElement.idl, AFAIK there is not a way to make that work using
> Settings.

I believe `[EnabledBySetting=Foo] attribute DOMString loading;` would work for this.
Comment 5 Rob Buis 2020-08-17 11:24:08 PDT
Comment on attachment 406716 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406716&action=review

>>>> Source/WebKit/Shared/WebPreferences.yaml:2038
>>>> +  webcoreBinding: RuntimeEnabledFeatures
>>> 
>>> What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.
>> 
>> This will be used though to enable the loading attribute in HTMLIFrameElement.idl, AFAIK there is not a way to make that work using Settings.
> 
> I believe `[EnabledBySetting=Foo] attribute DOMString loading;` would work for this.

Thanks, I was not aware of that. Does this mean LazyImageLoading runtime flag will need the same treatment?
Comment 6 Sam Weinig 2020-08-17 12:20:15 PDT
(In reply to Rob Buis from comment #5)
> Comment on attachment 406716 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406716&action=review
> 
> >>>> Source/WebKit/Shared/WebPreferences.yaml:2038
> >>>> +  webcoreBinding: RuntimeEnabledFeatures
> >>> 
> >>> What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.
> >> 
> >> This will be used though to enable the loading attribute in HTMLIFrameElement.idl, AFAIK there is not a way to make that work using Settings.
> > 
> > I believe `[EnabledBySetting=Foo] attribute DOMString loading;` would work for this.
> 
> Thanks, I was not aware of that. Does this mean LazyImageLoading runtime
> flag will need the same treatment?

Ideally, yes.
Comment 7 Rob Buis 2020-08-17 12:33:07 PDT
Created attachment 406731 [details]
Patch
Comment 8 EWS Watchlist 2020-08-17 12:33:52 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 9 Rob Buis 2020-08-17 12:34:49 PDT
Created attachment 406732 [details]
Patch
Comment 10 Rob Buis 2020-08-17 22:49:00 PDT
Comment on attachment 406716 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406716&action=review

>>>>>> Source/WebKit/Shared/WebPreferences.yaml:2038
>>>>>> +  webcoreBinding: RuntimeEnabledFeatures
>>>>> 
>>>>> What's the reason behind using RuntimeEnabledFeatures rather than the default, Settings? In general, I think we should always prefer Settings over RuntimeEnabledFeatures as they are not global singletons and are automatically accessible in layout tests via InternalSettingsGenerated.
>>>> 
>>>> This will be used though to enable the loading attribute in HTMLIFrameElement.idl, AFAIK there is not a way to make that work using Settings.
>>> 
>>> I believe `[EnabledBySetting=Foo] attribute DOMString loading;` would work for this.
>> 
>> Thanks, I was not aware of that. Does this mean LazyImageLoading runtime flag will need the same treatment?
> 
> Ideally, yes.

Thanks, will try to make a patch for that after this one.
Comment 11 youenn fablet 2020-08-19 02:10:21 PDT
Comment on attachment 406732 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406732&action=review

> LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-base-url-2.tentative.html:14
> +    internals.settings.setLazyIframeLoadingEnabled(true);

It would not be great to upstream these changes to WPT.
Either you could update testharnessreport.js to enable the setting or you could use <!-- webkit-test-runner -->
Comment 12 Rob Buis 2020-08-19 05:24:26 PDT
Created attachment 406842 [details]
Patch
Comment 13 Rob Buis 2020-08-19 05:27:55 PDT
Comment on attachment 406732 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406732&action=review

>> LayoutTests/imported/w3c/web-platform-tests/html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-base-url-2.tentative.html:14
>> +    internals.settings.setLazyIframeLoadingEnabled(true);
> 
> It would not be great to upstream these changes to WPT.
> Either you could update testharnessreport.js to enable the setting or you could use <!-- webkit-test-runner -->

Thanks, I attempted the testharnessreport.js approach, let me know if you had that in mind. If yes I suppose I should put it up on wpt first?
I don't think settings are set using <!-- webkit-test-runner --> before, so I think that one would need a lot of plumbing....
Comment 14 Radar WebKit Bug Importer 2020-08-24 07:04:18 PDT
<rdar://problem/67678075>
Comment 15 youenn fablet 2020-08-24 08:35:38 PDT
Comment on attachment 406842 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406842&action=review

> LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js:3674
> +    expose(enable_internal_setting, 'enable_internal_setting');

We do not want to touch testharness.js, this change should go in testharnessreport.js.
And we do not want to change the html/semantics/embedded-content/the-iframe-element/iframe-loading-xx files as well.

Something like the following in testharnessreport.js:
if (location.port == 8800 || location.port == 9443)
    internals.settings.setLazyIframeLoadingEnabled(true)

If you want to only enable lazy loading for these tests, you will need to write something like the following in testharnessreport.js:
if (location.port == 8800 || location.port == 9443)
    internals.settings.setLazyIframeLoadingEnabled(location.pathname.indexOf('iframe-loading-lazy') !== -1)

You can look at what we are doing for AudioContext there as an example.
Comment 16 Rob Buis 2020-08-25 05:45:19 PDT
Created attachment 407184 [details]
Patch
Comment 17 Rob Buis 2020-08-25 06:45:49 PDT
Comment on attachment 406842 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=406842&action=review

>> LayoutTests/imported/w3c/web-platform-tests/resources/testharness.js:3674
>> +    expose(enable_internal_setting, 'enable_internal_setting');
> 
> We do not want to touch testharness.js, this change should go in testharnessreport.js.
> And we do not want to change the html/semantics/embedded-content/the-iframe-element/iframe-loading-xx files as well.
> 
> Something like the following in testharnessreport.js:
> if (location.port == 8800 || location.port == 9443)
>     internals.settings.setLazyIframeLoadingEnabled(true)
> 
> If you want to only enable lazy loading for these tests, you will need to write something like the following in testharnessreport.js:
> if (location.port == 8800 || location.port == 9443)
>     internals.settings.setLazyIframeLoadingEnabled(location.pathname.indexOf('iframe-loading-lazy') !== -1)
> 
> You can look at what we are doing for AudioContext there as an example.

Thanks for the hints! I put up a new patch. I am not sure for the AudioContext example, maybe the patch is still under development?
Comment 18 youenn fablet 2020-08-25 08:28:46 PDT
Comment on attachment 407184 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=407184&action=review

> LayoutTests/imported/w3c/web-platform-tests/resources/testharnessreport.js:58
> +    }

This should go in LayoutTests/resources/testharnessreport.js which should override this file.
There is already a section with if (location.port == 8800 || location.port == 9443)
Comment 19 Rob Buis 2020-08-25 08:45:14 PDT
Created attachment 407194 [details]
Patch
Comment 20 EWS 2020-08-25 09:44:30 PDT
Committed r266127: <https://trac.webkit.org/changeset/266127>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 407194 [details].