Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b56577295e3d7564c3f3b74f0bd6cdb7647569e0
      
https://github.com/WebKit/WebKit/commit/b56577295e3d7564c3f3b74f0bd6cdb7647569e0
  Author: Said Abou-Hallawa <s...@apple.com>
  Date:   2023-04-18 (Tue, 18 Apr 2023)

  Changed paths:
    A LayoutTests/http/tests/images/render-partial-image-load-expected.html
    A LayoutTests/http/tests/images/render-partial-image-load.html
    M Source/WebCore/platform/graphics/ImageFrame.cpp
    M Source/WebCore/platform/graphics/ImageSource.cpp
    M Source/WebCore/platform/graphics/ImageSource.h

  Log Message:
  -----------
  Images are not drawn even after they are completely loaded from a slow server
https://bugs.webkit.org/show_bug.cgi?id=249645
rdar://103560731

Reviewed by Simon Fraser.

While loading a BitmapImage (i.e. allDataReceived is false), a partially decoded
NativeImage is created and cached in ImageFrame with DecodingStatus::Partial.

After loading the image is completed, ImageSource::cacheMetadataAtIndex() gets
called with the default DecodingStatus which is DecodingStatus::Invalid. This
forces recalculating a new DecodingStatus which will be 
DecodingStatus::Complete.

So the ImageFrame will have partially decoded NativeImage and DecodingStatus::
Complete. The next draw ImageFrame::hasDecodedNativeImageCompatibleWithOptions()
will return true and a stale NativeImage is drawn, which usually draws nothing
except for JPEG images.

It turns out we were setting ImageFrame::m_decodingStatus incorrectly always 
when
decoding an image asynchronously on GTK and WPE ports. We get the decodingStatus
of the frame when requesting it to be asynchronously decoded. This is calculated
by calling frameIsCompleteAtIndex(). 
ScalableImageDecoder::frameIsCompleteAtIndex()
returns false always if we have not decoded the frame yet.

The fix is to let ImageSource::cachePlatformImageAtIndex() be the only place to
set the ImageFrame::m_decodingStatus since it is the only setter for the
ImageFrame::nativeImage and we are sure at this point frameIsCompleteAtIndex()
will return the correct value for all ports.

* LayoutTests/http/tests/images/render-partial-image-load-expected.html: Added.
* LayoutTests/http/tests/images/render-partial-image-load.html: Added.
* Source/WebCore/platform/graphics/ImageFrame.cpp:
(WebCore::ImageFrame::hasDecodedNativeImageCompatibleWithOptions const):
* Source/WebCore/platform/graphics/ImageSource.cpp:
(WebCore::ImageSource::cacheMetadataAtIndex):
(WebCore::ImageSource::cachePlatformImageAtIndex):
(WebCore::ImageSource::cachePlatformImageAtIndexAsync):
(WebCore::ImageSource::startAsyncDecodingQueue):
(WebCore::ImageSource::requestFrameAsyncDecodingAtIndex):
(WebCore::ImageSource::frameAtIndexCacheIfNeeded):
* Source/WebCore/platform/graphics/ImageSource.h:

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


_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to