Bug 215998 - Fix crash in image-loading-lazy-slow.html WPT test
Summary: Fix crash in image-loading-lazy-slow.html WPT test
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Images (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Rob Buis
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2020-08-31 02:41 PDT by Rob Buis
Modified: 2020-11-27 13:59 PST (History)
9 users (show)

See Also:


Attachments
Patch (5.75 KB, patch)
2020-09-04 05:00 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (5.98 KB, patch)
2020-09-04 07:36 PDT, Rob Buis
no flags Details | Formatted Diff | Diff
Patch (7.69 KB, patch)
2020-09-07 01:46 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-31 02:41:03 PDT
Make image-loading-lazy-slow.html pass. Note that this was not tested before because it had no custom webkit-test-runner directive to enable lazy image loading.
Comment 1 Rob Buis 2020-09-04 05:00:12 PDT
Created attachment 407961 [details]
Patch
Comment 2 EWS Watchlist 2020-09-04 05:00:57 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 3 Rob Buis 2020-09-04 07:36:32 PDT
Created attachment 407968 [details]
Patch
Comment 4 youenn fablet 2020-09-04 08:05:22 PDT
Comment on attachment 407968 [details]
Patch

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

> Source/WebCore/loader/ImageLoader.cpp:280
> +            if (document.lazyLoadImageObserver().isObserved(element()))

Do we need this if check?

> Source/WebCore/loader/ImageLoader.cpp:281
> +                LazyLoadImageObserver::unobserve(element(), element().document());

This is ok as is, but it would be a bit better if it was reverse so that we unobserve closer to setting m_image.
Something like:
if (!m_image)
   unobserve....

There are other code paths that sets back m_image to nullptr.
Should we unobserve in those cases as well?

Maybe we should introduce a clearImage() method that would set back m_image to nullptr and unobserve.
Comment 5 Alexey Proskuryakov 2020-09-04 19:25:57 PDT
Comment on attachment 407968 [details]
Patch

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

> LayoutTests/ChangeLog:8
> +        Mark image-loading-lazy-slow.html as ImageOnlyFailure.

So this patch doesn't do what its title says?
Comment 6 Rob Buis 2020-09-07 01:41:21 PDT
(In reply to Alexey Proskuryakov from comment #5)
> Comment on attachment 407968 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=407968&action=review
> 
> > LayoutTests/ChangeLog:8
> > +        Mark image-loading-lazy-slow.html as ImageOnlyFailure.
> 
> So this patch doesn't do what its title says?

You are right, I was expecting the test would pass once the crash is fixed, but with the crash fixed we run into https://bugs.webkit.org/show_bug.cgi?id=186045.
Comment 7 Rob Buis 2020-09-07 01:46:18 PDT
Created attachment 408165 [details]
Patch
Comment 8 Radar WebKit Bug Importer 2020-09-07 02:42:11 PDT
<rdar://problem/68454263>
Comment 9 Rob Buis 2020-09-07 05:41:35 PDT
Comment on attachment 407968 [details]
Patch

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

>> Source/WebCore/loader/ImageLoader.cpp:280
>> +            if (document.lazyLoadImageObserver().isObserved(element()))
> 
> Do we need this if check?

Right, that one was a bit ugly, I changed isDeferred to include testing for LoadImmediate, and instead of above check check for isDeferred.

>> Source/WebCore/loader/ImageLoader.cpp:281
>> +                LazyLoadImageObserver::unobserve(element(), element().document());
> 
> This is ok as is, but it would be a bit better if it was reverse so that we unobserve closer to setting m_image.
> Something like:
> if (!m_image)
>    unobserve....
> 
> There are other code paths that sets back m_image to nullptr.
> Should we unobserve in those cases as well?
> 
> Maybe we should introduce a clearImage() method that would set back m_image to nullptr and unobserve.

I think in the other places we do not need to unobserve. But I added a method resetLazyImageLoading which we can re-use if needed.
Comment 10 EWS 2020-09-08 04:59:47 PDT
Committed r266720: <https://trac.webkit.org/changeset/266720>

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