<?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>93772</bug_id>
          
          <creation_ts>2012-08-11 18:18:51 -0700</creation_ts>
          <short_desc>SVG as image drawn differently after layout</short_desc>
          <delta_ts>2022-07-15 15:27:57 -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>SVG</component>
          <version>420+</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>CONFIGURATION CHANGED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>94377</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Philip Rogers">pdr</reporter>
          <assigned_to name="Philip Rogers">pdr</assigned_to>
          <cc>bfulgham</cc>
    
    <cc>dtrebbien</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>693159</commentid>
    <comment_count>0</comment_count>
      <attachid>157882</attachid>
    <who name="Philip Rogers">pdr</who>
    <bug_when>2012-08-11 18:18:51 -0700</bug_when>
    <thetext>Created attachment 157882
Testcase (1 of 2)

If we have an SVG file referenced as an image, the image will draw differently depending on if a layout has occurred:

        image.onload = function() {
            var context1 = canvas1.getContext(&apos;2d&apos;);
            context1.drawImage(img, 0, 0); // draws correctly

            setTimeout(function(){
                var context2 = canvas2.getContext(&apos;2d&apos;);
                context2.drawImage(img, 0, 0); // draws incorrectly, scaled 2x?
            }, 1);
        }

My guess is we&apos;re changing the size of the SVG during layout. This could be the source of a bug I&apos;ve seen sporadically where SVG embedded in an image renders incorrectly on first load.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>693160</commentid>
    <comment_count>1</comment_count>
      <attachid>157883</attachid>
    <who name="Philip Rogers">pdr</who>
    <bug_when>2012-08-11 18:19:19 -0700</bug_when>
    <thetext>Created attachment 157883
Testcase (2 of 2)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>694545</commentid>
    <comment_count>2</comment_count>
    <who name="Philip Rogers">pdr</who>
    <bug_when>2012-08-13 23:18:47 -0700</bug_when>
    <thetext>Just updating to report what I&apos;ve found so far. I think there is more than one bug hiding in here :(

I think one bug is that we use the device scale factor in calculating the bitmap size in SVGImageCache.cpp. It looks like implementations have steered towards doing that one level deeper (see http://code.google.com/p/chromium/issues/detail?id=127852). This isn&apos;t surprising since this code was written long ago.

A second bug is that on the first drawImage() call we have not done a layout of the SVG image, so it does not have size and scales set, and so we end up using drawImage directly. On the second drawImage() we have done a layout so we have cached data, but the cached data has zoom applied. The second drawImage therefore has zoom applied twice.

This second bug may get more complex because as a part of fixing our SVG sizing issues, it looks like a layout may be needed just to determine the aspect ratio of SVG content.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1884299</commentid>
    <comment_count>3</comment_count>
    <who name="Brent Fulgham">bfulgham</who>
    <bug_when>2022-07-15 15:27:57 -0700</bug_when>
    <thetext>Safari, Chrome, and Firefox all agree on rendering for this test case. I don&apos;t believe there is any remaining compatibility issue.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>157882</attachid>
            <date>2012-08-11 18:18:51 -0700</date>
            <delta_ts>2012-08-11 18:18:51 -0700</delta_ts>
            <desc>Testcase (1 of 2)</desc>
            <filename>bug.html</filename>
            <type>text/html</type>
            <size>1291</size>
            <attacher name="Philip Rogers">pdr</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh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VudEJ5SWQoJ2ltZycpOwogICAgICAgIHZhciBjYW52
YXMxID0gZG9jdW1lbnQuZ2V0RWxlbWVudEJ5SWQoJ2NhbnZhczEnKTsKICAgICAgICB2YXIgY2Fu
dmFzMiA9IGRvY3VtZW50LmdldEVsZW1lbnRCeUlkKCdjYW52YXMyJyk7CgogICAgICAgIGltZ1Nv
dXJjZS5vbmxvYWQgPSBmdW5jdGlvbigpIHsKICAgICAgICAgICAgdmFyIGNvbnRleHQxID0gY2Fu
dmFzMS5nZXRDb250ZXh0KCcyZCcpOwogICAgICAgICAgICBjb250ZXh0MS5kcmF3SW1hZ2UoaW1n
LCAwLCAwKTsKCiAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKXsKICAgICAgICAgICAg
ICAgIHZhciBjb250ZXh0MiA9IGNhbnZhczIuZ2V0Q29udGV4dCgnMmQnKTsKICAgICAgICAgICAg
ICAgIGNvbnRleHQyLmRyYXdJbWFnZShpbWcsIDAsIDApOwogICAgICAgICAgICB9LCAxKTsKICAg
ICAgICB9CiAgICA8L3NjcmlwdD4KPC9ib2R5Pgo8L2h0bWw+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>157883</attachid>
            <date>2012-08-11 18:19:19 -0700</date>
            <delta_ts>2012-08-11 18:19:19 -0700</delta_ts>
            <desc>Testcase (2 of 2)</desc>
            <filename>svg.svg</filename>
            <type>image/svg+xml</type>
            <size>188</size>
            <attacher name="Philip Rogers">pdr</attacher>
            
              <data encoding="base64">PHN2ZyBpZD0ic3ZnIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCIgeG1sbnM9Imh0dHA6Ly93d3cu
dzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGlu
ayI+CiAgICAgIDxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxs
PSJncmVlbiIvPgo8L3N2Zz4=
</data>

          </attachment>
      

    </bug>

</bugzilla>