Bug 277495
| Summary: | REGRESSION(278195@main): A bitmap image may get the size of a subsampled frame | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Said Abou-Hallawa <sabouhallawa> |
| Component: | Images | Assignee: | Said Abou-Hallawa <sabouhallawa> |
| Status: | RESOLVED FIXED | ||
| Severity: | Normal | CC: | sabouhallawa, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| See Also: |
https://bugs.webkit.org/show_bug.cgi?id=273457 https://bugs.webkit.org/show_bug.cgi?id=265363 |
||
Said Abou-Hallawa
A subsampled frame can help in displaying the image into a smaller destination rectangle because decoding and displaying it is faster than the default frame. Some of the subsampled frame metadata can be the same as the default frame such as, hasAlpha, orientation and animation duration. But the image size can't be retrieved from subsampled frame. We have to get the size of the default frame to get the image size correctly.
278195@main made it possible to return the size of any cached frame even if it is subsampled frame.
To get the size of an image, BitmapImage::size() calls BitmapImageSource::size() which calls BitmapImageDescriptor::size().
BitmapImageDescriptor::sourceSize() calls BitmapImageDescriptor::primaryImageFrameMetadata() which calls BitmapImageSource::primaryImageFrame() which calls BitmapImageSource::frameAtIndexCacheIfNeeded() with std::nullopt for SubsamplingLevel.
If the ImageFrame is cached and SubsamplingLevel is equal to std::nullopt, BitmapImageSource::frameAtIndexCacheIfNeeded() will return it because of this code:
auto& frame = m_frames[index];
auto subsamplingLevelValue = subsamplingLevel.value_or(frame.subsamplingLevel());
if (frame.isComplete() && subsamplingLevelValue == frame.subsamplingLevel())
return frame;
To fix this issue, we need to ensure the default frame is retrieved and cached if the size of the image is required.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Said Abou-Hallawa
rdar://129703072
Said Abou-Hallawa
Pull request: https://github.com/WebKit/WebKit/pull/31607
EWS
Committed 281731@main (2f897eb8b838): <https://commits.webkit.org/281731@main>
Reviewed commits have been landed. Closing PR #31607 and removing active labels.