<?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>198527</bug_id>
          
          <creation_ts>2019-06-04 06:30:41 -0700</creation_ts>
          <short_desc>HTMLImage​Element​.decode() method doesn&apos;t work for SVG files</short_desc>
          <delta_ts>2019-11-13 13:49:05 -0800</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 12</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>DUPLICATE</resolution>
          <dup_id>201243</dup_id>
          
          <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="Frederic Junod">frederic.junod</reporter>
          <assigned_to name="Said Abou-Hallawa">sabouhallawa</assigned_to>
          <cc>achristensen</cc>
    
    <cc>cdumez</cc>
    
    <cc>dpaddock</cc>
    
    <cc>jkieboom</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>thorton</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1541536</commentid>
    <comment_count>0</comment_count>
    <who name="Frederic Junod">frederic.junod</who>
    <bug_when>2019-06-04 06:30:41 -0700</bug_when>
    <thetext>The HTMLImage​Element​.decode() method never resolves when the src references a SVG image.


To reproduce the issue:
```
const img = new Image();
img.src = &apos;https://unpkg.com/@mapbox/maki@4.0.0/icons/fuel-15.svg&apos;;
img.decode()
  .then(() =&gt; {
    console.log(&apos;loaded&apos;);
  })
  .catch(() =&gt; {
    console.log(&apos;error&apos;);
  });

```

Expected behavior:

`loaded` is displayed in the console. (this is the case on Chromium and Firefox)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542472</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2019-06-06 10:22:37 -0700</bug_when>
    <thetext>&lt;rdar://problem/51488679&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542524</commentid>
    <comment_count>2</comment_count>
      <attachid>371520</attachid>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2019-06-06 12:25:24 -0700</bug_when>
    <thetext>Created attachment 371520
decode-svg</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542525</commentid>
    <comment_count>3</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2019-06-06 12:26:08 -0700</bug_when>
    <thetext>What is the meaning of decoding an SVG image? And why do you expect the decode() promise to be resolved rather than being rejected?

The specs https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-decode says:

    image . decode()
    This method causes the user agent to decode the image in parallel, returning a promise that fulfills when decoding is complete.

    The promise will be rejected with an &quot;EncodingError&quot; DOMException if the image cannot be decoded.

Since the SVG image cannot be decoded, the promise is rejected. Open the attached test case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542532</commentid>
    <comment_count>4</comment_count>
    <who name="Frederic Junod">frederic.junod</who>
    <bug_when>2019-06-06 13:03:03 -0700</bug_when>
    <thetext>I understand that an SVG image doesn&apos;t needs to be decoded but the promise could nevertheless be resolved.

Context: the decode function is used in the OpenLayers library [1] to load and decode images in any format

See also: https://chromium-review.googlesource.com/c/chromium/src/+/585220/


[1] https://github.com/openlayers/openlayers/blob/v6.0.0-beta.9/src/ol/Image.js#L160-L175</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1542574</commentid>
    <comment_count>5</comment_count>
    <who name="Simon Fraser (smfr)">simon.fraser</who>
    <bug_when>2019-06-06 15:39:08 -0700</bug_when>
    <thetext>The spec is explicit about vector images:
&quot;If decoding does not need to be performed for this image (for example because it is a vector graphic), resolve promise with undefined.&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1590027</commentid>
    <comment_count>6</comment_count>
    <who name="Said Abou-Hallawa">sabouhallawa</who>
    <bug_when>2019-11-13 13:49:05 -0800</bug_when>
    <thetext>This was fixed in r249367 and r249594.

*** This bug has been marked as a duplicate of bug 201243 ***</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>371520</attachid>
            <date>2019-06-06 12:25:24 -0700</date>
            <delta_ts>2019-06-06 12:26:29 -0700</delta_ts>
            <desc>decode-svg</desc>
            <filename>decode-svg.html</filename>
            <type>text/html</type>
            <size>297</size>
            <attacher name="Said Abou-Hallawa">sabouhallawa</attacher>
            
              <data encoding="base64">PGJvZHk+CiAgICA8c2NyaXB0PgogICAgICAgIGNvbnN0IGltZyA9IG5ldyBJbWFnZSgpOwogICAg
ICAgIGltZy5zcmMgPSAnaHR0cHM6Ly91bnBrZy5jb20vQG1hcGJveC9tYWtpQDQuMC4wL2ljb25z
L2Z1ZWwtMTUuc3ZnJzsKICAgICAgICBpbWcuZGVjb2RlKCkKICAgICAgICAudGhlbigoKSA9PiB7
CiAgICAgICAgICAgIGFsZXJ0KCdsb2FkZWQnKTsKICAgICAgICB9KQogICAgICAgIC5jYXRjaCgo
KSA9PiB7CiAgICAgICAgICAgIGFsZXJ0KCdlcnJvcicpOwogICAgICAgIH0pOwogICAgPC9zY3Jp
cHQ+CjwvYm9keT4K
</data>

          </attachment>
      

    </bug>

</bugzilla>