<?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>215375</bug_id>
          
          <creation_ts>2020-08-11 08:44:33 -0700</creation_ts>
          <short_desc>Inserting image with srcset into dynamically created iframe results in invisible image</short_desc>
          <delta_ts>2026-04-02 11:45:46 -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>Safari 13</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://github.com/web-platform-tests/wpt/pull/58959</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>BrowserCompat, InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Comandeer">vepomoc</reporter>
          <assigned_to name="Ahmad Saleem">ahmad.saleem792</assigned_to>
          <cc>ahmad.saleem792</cc>
    
    <cc>koivisto</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>zalan</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1679402</commentid>
    <comment_count>0</comment_count>
    <who name="Comandeer">vepomoc</who>
    <bug_when>2020-08-11 08:44:33 -0700</bug_when>
    <thetext>Demo of the bug: https://jsfiddle.net/6Le9nwx7/

Inserting image with [srcset] attribute into dynamically created iframe results in the image that has its natural dimensions set to 0, therefore – it&apos;s not visible.

Tested on Safari 13.1.2 (15609.3.5.1.3).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1679464</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2020-08-11 10:53:27 -0700</bug_when>
    <thetext>&lt;rdar://problem/66849050&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1679473</commentid>
    <comment_count>2</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2020-08-11 11:14:30 -0700</bug_when>
    <thetext>Chrome also says 0x0. Firefox gives a size.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1679651</commentid>
    <comment_count>3</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2020-08-11 16:44:52 -0700</bug_when>
    <thetext>(In reply to Simon Fraser (smfr) from comment #2)
&gt; Chrome also says 0x0. Firefox gives a size.

This happens because the &apos;sizes&apos; attribute is missing from the &lt;img&gt; tag. So in HTMLImageElement::selectImageSource(), we end up having sourceSize = 0.

And in pickBestImageCandidate(), we do this calculation:

    candidate.density = static_cast&lt;float&gt;(candidate.resourceWidth) / sourceSize;

but because sourceSize = 0, we calculate candidate.density = +inf.

And in HTMLImageElement::setBestFitURLAndDPRFromImageCandidate(), we do this calculation:

    m_imageDevicePixelRatio = 1 / candidate.density;

So we end up having m_imageDevicePixelRatio = 0. And this is why HTMLImageElement::naturalWidth() returns zero.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1945914</commentid>
    <comment_count>4</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2023-03-31 22:47:04 -0700</bug_when>
    <thetext>(In reply to Comandeer from comment #0)
&gt; Demo of the bug: https://jsfiddle.net/6Le9nwx7/
&gt; 
&gt; Inserting image with [srcset] attribute into dynamically created iframe
&gt; results in the image that has its natural dimensions set to 0, therefore –
&gt; it&apos;s not visible.
&gt; 
&gt; Tested on Safari 13.1.2 (15609.3.5.1.3).

Firefox Nightly 113: 300x372

Chrome Canary 113: 300x372 

Safari Technology Preview 166: 0x0</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196168</commentid>
    <comment_count>5</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-04-01 23:08:36 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/61886</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196325</commentid>
    <comment_count>6</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2026-04-02 10:03:02 -0700</bug_when>
    <thetext>Committed 310446@main (088193491341): &lt;https://commits.webkit.org/310446@main&gt;

Reviewed commits have been landed. Closing PR #61886 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>2196353</commentid>
    <comment_count>7</comment_count>
    <who name="Ahmad Saleem">ahmad.saleem792</who>
    <bug_when>2026-04-02 11:45:46 -0700</bug_when>
    <thetext>Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/58959</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>