⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 294747 in webkit


Ignore:
Timestamp:
May 24, 2022, 8:24:58 AM (4 years ago)
Author:
Wenson Hsieh
Message:

ImageAnalysisTests.AnalyzeDynamicallyLoadedImages is a flaky timeout
https://bugs.webkit.org/show_bug.cgi?id=240847
rdar://93268890

Reviewed by Tim Horton.

This API test was created to verify that ImageAnalysisQueue detects and enqueues images that are
inserted into the document via script, after -_startImageAnalysis: has been invoked. Currently, it
occasionally times out, when the logic in ImageAnalysisQueue::enqueueIfNeeded to reject tiny
(< 20 by 20) images from the analysis queue falsely prevents us from enqueueing the newly inserted
image element.

Note that enqueueIfNeeded is called after the image has finished loading (i.e., dispatched its
"load" event for the new image). However, in this state, the image element's renderer hasn't
necessarily been laid out yet since its image source has changed, which means that the actual size
of the renderer might still be empty (0 by 0) when invoking enqueueIfNeeded. Since we currently
consult RenderBox::size() on the RenderImage in this method, we end up bailing too early.

Instead of checking the size of the renderer, we should be checking the size of the image instead
since the image itself is what's used to generate the bitmap image, over which we'll eventually run
image analysis. Unlike the renderer, this cached image's size doesn't depend on layout, and is
guaranteed to be up to date when the image has finished loading. This also allows us to simplify the
logic here -- since null WebCore::Images are empty, checking that both the width and height of the
image are at least 20 is sufficient to avoid queueing null images for analysis.

  • Source/WebCore/page/ImageAnalysisQueue.cpp:

(WebCore::ImageAnalysisQueue::enqueueIfNeeded):

Canonical link: https://commits.webkit.org/250915@main

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/page/ImageAnalysisQueue.cpp

    r294325 r294747  
    6666
    6767    auto* image = cachedImage->image();
    68     if (!image || image->isNull())
    69         return;
    70 
    71     if (renderer.size().width() < minimumWidthForAnalysis || renderer.size().height() < minimumHeightForAnalysis)
     68    if (!image || image->width() < minimumWidthForAnalysis || image->height() < minimumHeightForAnalysis)
    7269        return;
    7370
Note: See TracChangeset for help on using the changeset viewer.