<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>277495</bug_id>
          
          <creation_ts>2024-08-01 11:46:23 -0700</creation_ts>
          <short_desc>REGRESSION(278195@main): A bitmap image may get the size of a subsampled frame</short_desc>
          <delta_ts>2024-08-01 15:20:47 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=273457</see_also>
    
    <see_also>https://bugs.webkit.org/show_bug.cgi?id=265363</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Said Abou-Hallawa">sabouhallawa</reporter>
          <assigned_to name="Said Abou-Hallawa">sabouhallawa</assigned_to>
          <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>2050117</commentid>
    <comment_count>0</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2024-08-01 11:46:23 -0700</bug_when>
    <thetext>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&apos;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&amp; frame = m_frames[index];
    auto subsamplingLevelValue = subsamplingLevel.value_or(frame.subsamplingLevel());

    if (frame.isComplete() &amp;&amp; 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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2050118</commentid>
    <comment_count>1</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2024-08-01 11:46:52 -0700</bug_when>
    <thetext>rdar://129703072</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2050126</commentid>
    <comment_count>2</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2024-08-01 11:57:37 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/31607</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2050176</commentid>
    <comment_count>3</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2024-08-01 15:20:45 -0700</bug_when>
    <thetext>Committed 281731@main (2f897eb8b838): &lt;https://commits.webkit.org/281731@main&gt;

Reviewed commits have been landed. Closing PR #31607 and removing active labels.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>