Bug 240083

Summary: Use correct document as root for lazy image observer
Product: WebKit Reporter: dukejoon
Component: ImagesAssignee: Rob Buis <rbuis>
Status: RESOLVED FIXED    
Severity: Critical CC: cdumez, changseok, clopez, esprehn+autocc, ews-watchlist, gyuyoung.kim, martin.schoen, nmouchtaris, rbuis, sabouhallawa, simon.fraser, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: Safari 15   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=237703
https://github.com/web-platform-tests/wpt/pull/33971
Attachments:
Description Flags
Patch
none
Patch none

Description dukejoon 2022-05-04 15:00:15 PDT
Hi,

In Safari 15.4 we've noticed an error with the attribute loading="lazy". HTML img tag with this attribute are not loading consistently. If you check the network tab you will see that the images are not being requested at all. So far, the solution is to remove the attribute or use loading="eager".

You can successfully replicate it with this codesanbox (https://codepen.io/intellix/pen/JjMwWae). Found it here (https://github.com/Fyrd/caniuse/issues/6243).

Additionally if you go to "Develop > Experimental Features" and disable "Lazy image loading" the images with loading="lazy" will load consistently.
Comment 1 Rob Buis 2022-05-05 08:21:44 PDT
The html seems to work fine in a standalone file, but as soon as it is embedded in an iframe no image load is triggered.
Comment 2 Radar WebKit Bug Importer 2022-05-05 09:01:16 PDT
<rdar://problem/92798878>
Comment 3 Rob Buis 2022-05-05 11:54:33 PDT
Created attachment 458903 [details]
Patch
Comment 4 Simon Fraser (smfr) 2022-05-05 13:22:35 PDT
Comment on attachment 458903 [details]
Patch

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

> Source/WebCore/ChangeLog:8
> +        Use document as root for lazy image observer.

The iframe's document?
Comment 5 Simon Fraser (smfr) 2022-05-05 13:23:04 PDT
Can you test lazy image loading with Command-+ zoom too? I believe we might have some intersection observer bugs with zooming.
Comment 6 Rob Buis 2022-05-06 08:38:22 PDT
Created attachment 458952 [details]
Patch
Comment 7 EWS Watchlist 2022-05-06 08:39:49 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 8 EWS 2022-05-06 17:09:29 PDT
Committed r293933 (250379@main): <https://commits.webkit.org/250379@main>

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