<?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>177068</bug_id>
          
          <creation_ts>2017-09-18 06:04:35 -0700</creation_ts>
          <short_desc>Creating a picture element with a source and img element triggers loading of both sources</short_desc>
          <delta_ts>2020-09-01 09:25:18 -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>Mac</rep_platform>
          <op_sys>macOS 10.12</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>159484</dup_id>
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=190031</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>maximuse.chern</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>daniel</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1349874</commentid>
    <comment_count>0</comment_count>
      <attachid>321087</attachid>
    <who name="">maximuse.chern</who>
    <bug_when>2017-09-18 06:04:35 -0700</bug_when>
    <thetext>Created attachment 321087
Reduced test case

When an image element is created:

&gt; const image = document.createElement(&apos;img&apos;);
&gt; image.setAttribute(&apos;srcset&apos;, &apos;https://via.placeholder.com/300x100/0e7f00&apos;);

webkit starts preloading the srcset immediately.

However, when an image is intended to become part of a picture tag:

&gt; const picture = document.createElement(&apos;picture&apos;);
&gt; const source = document.createElement(&apos;source&apos;);
&gt; const image = document.createElement(&apos;img&apos;);
&gt; 
&gt; source.setAttribute(&apos;sizes&apos;, &apos;100vw&apos;);
&gt; source.setAttribute(&apos;media&apos;, &apos;(orientation: portrait)&apos;);
&gt; 
&gt; image.setAttribute(&apos;sizes&apos;, &apos;100vw&apos;);
&gt; image.setAttribute(&apos;alt&apos;, &apos;Placeholder&apos;); 
&gt; 
&gt; source.setAttribute(&apos;srcset&apos;, &apos;https://via.placeholder.com/550x900/6600af 550w, https://via.placeholder.com/750x1000/a100af 750w&apos;); 
&gt; image.setAttribute(&apos;srcset&apos;, &apos;https://via.placeholder.com/300x100/0e7f00&apos;); 
&gt; 
&gt; picture.appendChild(source);
&gt; picture.appendChild(image);

I expect either the source or the image to be loaded depending on the media query, not both.

# Actual
Webkit preloads the image tag, and the source tag when it is added to the picture element.

# Expected
Only the source tag to be loaded when (orientation: portrait) or only the img to be loaded when (orientation: landscape).


Chrome handles this scenario correctly by cancelling the initial request for the image&apos;s srcset when it becomes a child of the picture element.

Reduced test case: https://s.codepen.io/maximus8891/debug/LzVjNZ/ZorBajwPWeOM

Possible duplicates:
https://bugs.webkit.org/show_bug.cgi?id=6656
https://bugs.webkit.org/show_bug.cgi?id=35377</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1350084</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2017-09-18 14:05:41 -0700</bug_when>
    <thetext>&lt;rdar://problem/34500892&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1684492</commentid>
    <comment_count>2</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2020-09-01 09:25:18 -0700</bug_when>
    <thetext>This is the same as bug 159484. They both address the issue of loading multiple resources for the same &lt;picture&gt; element although a single resource will be displayed at the end.

*** This bug has been marked as a duplicate of bug 159484 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>321087</attachid>
            <date>2017-09-18 06:04:35 -0700</date>
            <delta_ts>2017-09-18 06:04:35 -0700</delta_ts>
            <desc>Reduced test case</desc>
            <filename>file_177068.txt</filename>
            <type>text/plain</type>
            <size>775</size>
            <attacher>maximuse.chern</attacher>
            
              <data encoding="base64">PHNjcmlwdD4NCiAgKF8gPT4gew0KICAgIGNvbnN0IHBpY3R1cmUgPSBkb2N1bWVudC5jcmVhdGVF
bGVtZW50KCdwaWN0dXJlJyk7DQogICAgY29uc3Qgc291cmNlID0gZG9jdW1lbnQuY3JlYXRlRWxl
bWVudCgnc291cmNlJyk7DQogICAgY29uc3QgaW1hZ2UgPSBkb2N1bWVudC5jcmVhdGVFbGVtZW50
KCdpbWcnKTsNCg0KICAgIHNvdXJjZS5zZXRBdHRyaWJ1dGUoJ3NpemVzJywgJzEwMHZ3Jyk7DQog
ICAgc291cmNlLnNldEF0dHJpYnV0ZSgnbWVkaWEnLCAnKG9yaWVudGF0aW9uOiBwb3J0cmFpdCkn
KTsNCg0KICAgIGltYWdlLnNldEF0dHJpYnV0ZSgnc2l6ZXMnLCAnMTAwdncnKTsNCiAgICBpbWFn
ZS5zZXRBdHRyaWJ1dGUoJ2FsdCcsICdQbGFjZWhvbGRlcicpOyANCg0KICAgIHNvdXJjZS5zZXRB
dHRyaWJ1dGUoJ3NyY3NldCcsICdodHRwczovL3ZpYS5wbGFjZWhvbGRlci5jb20vNTUweDkwMC82
NjAwYWYgNTUwdywgaHR0cHM6Ly92aWEucGxhY2Vob2xkZXIuY29tLzc1MHgxMDAwL2ExMDBhZiA3
NTB3Jyk7IA0KICAgIGltYWdlLnNldEF0dHJpYnV0ZSgnc3Jjc2V0JywgJ2h0dHBzOi8vdmlhLnBs
YWNlaG9sZGVyLmNvbS8zMDB4MTAwLzBlN2YwMCcpOyANCg0KICAgIHBpY3R1cmUuYXBwZW5kQ2hp
bGQoc291cmNlKTsNCiAgICAvLyBVbmNvbW1lbnQgdG8gbG9hZCB0d28gaW1hZ2VzDQogICAgLy8g
c2V0VGltZW91dCgoKSA9PiB7DQogICAgICBwaWN0dXJlLmFwcGVuZENoaWxkKGltYWdlKTsNCiAg
ICAvLyB9LCAxNTAwKTsNCiAgfSkoKTsNCjwvc2NyaXB0Pg==
</data>

          </attachment>
      

    </bug>

</bugzilla>