Bug 148845 - An SVG inherits the container size of the previously drawn HTMLImageElement when drawing it on a canvas
Summary: An SVG inherits the container size of the previously drawn HTMLImageElement w...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Said Abou-Hallawa
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2015-09-04 16:27 PDT by Said Abou-Hallawa
Modified: 2015-09-28 00:44 PDT (History)
6 users (show)

See Also:


Attachments
test case (1.72 KB, text/html)
2015-09-04 16:27 PDT, Said Abou-Hallawa
no flags Details
Patch (17.61 KB, patch)
2015-09-25 22:54 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews100 for mac-mavericks (609.57 KB, application/zip)
2015-09-25 23:27 PDT, Build Bot
no flags Details
Patch (17.63 KB, patch)
2015-09-27 18:19 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews103 for mac-mavericks (611.42 KB, application/zip)
2015-09-27 18:51 PDT, Build Bot
no flags Details
Patch (8.61 KB, patch)
2015-09-27 21:44 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-mavericks (609.97 KB, application/zip)
2015-09-27 22:33 PDT, Build Bot
no flags Details
Patch (8.46 KB, patch)
2015-09-27 23:15 PDT, Said Abou-Hallawa
no flags Details | Formatted Diff | Diff
test case (3.66 KB, text/html)
2015-09-28 00:02 PDT, Said Abou-Hallawa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Said Abou-Hallawa 2015-09-04 16:27:32 PDT
Created attachment 260645 [details]
test case

Open the attached test case.

Result: Two rectangles are drawn. The first one is 10x10 and the second one is 100x100.
Expected: The two rectangles should have size of 100x100.

Notes:

1. The first rectangle is an <img> tag. Its size is 100x100 and its src is set to a a data uri SVG.
3. The second rectangle is a canvas which loads the same data uri SVG and draws it to a rectangle of 100x100.
2. The SVG does not have an intrinsic size. But it has a viewBox of "0 0 1000 1000".

The bug does not happen with the same test case if any of the following happens:

1. The <img> tag is removed (so the canvas does not get the image resource from the cache).
2. The data uri SVG has an intrinsic size.
3. The viewBox is "0 0 100 100".
Comment 1 Said Abou-Hallawa 2015-09-04 16:28:23 PDT
<rdar://problem/22530820>
Comment 2 Said Abou-Hallawa 2015-09-25 22:54:59 PDT
Created attachment 261962 [details]
Patch
Comment 3 Build Bot 2015-09-25 23:27:36 PDT
Comment on attachment 261962 [details]
Patch

Attachment 261962 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/213121

New failing tests:
svg/as-image/svg-cached-draw-canvas.html
Comment 4 Build Bot 2015-09-25 23:27:40 PDT
Created attachment 261965 [details]
Archive of layout-test-results from ews100 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews100  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 5 Darin Adler 2015-09-26 18:57:22 PDT
Comment on attachment 261962 [details]
Patch

All the name changes from image to imageElement obscure the substance of the code change. Might be nicer as two separate patches.

Looks like this changes the result of the svg/as-image/svg-cached-draw-canvas.html test.
Comment 6 Said Abou-Hallawa 2015-09-27 18:17:24 PDT
(In reply to comment #5)
> Comment on attachment 261962 [details]
> Patch
> 
> All the name changes from image to imageElement obscure the substance of the
> code change. Might be nicer as two separate patches.

I will submit two patches as suggested.

> 
> Looks like this changes the result of the
> svg/as-image/svg-cached-draw-canvas.html test.

The test fails only on the bots; it passes locally. It happens because of the image smoothing which happens when drawing two colors on the canvas. The pixels on the boundaries get a mixed color.

Actually drawing an SVG with a single color on the canvas is sufficient. I was trying to make sure the SVG is scaled down and not clipped. With a single color, there is no difference between scaling and non-clipping.

I will try fixing this by setting the context flag imageSmoothingEnabled to false and see if the test passes on the bots.
Comment 7 Said Abou-Hallawa 2015-09-27 18:19:09 PDT
Created attachment 261995 [details]
Patch
Comment 8 Build Bot 2015-09-27 18:51:36 PDT
Comment on attachment 261995 [details]
Patch

Attachment 261995 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/218768

New failing tests:
svg/as-image/svg-cached-draw-canvas.html
Comment 9 Build Bot 2015-09-27 18:51:41 PDT
Created attachment 261996 [details]
Archive of layout-test-results from ews103 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews103  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 10 Said Abou-Hallawa 2015-09-27 21:24:00 PDT
The renaming patch is:

Committed r190273: <http://trac.webkit.org/changeset/190273>.
Comment 11 Said Abou-Hallawa 2015-09-27 21:44:54 PDT
Created attachment 261998 [details]
Patch
Comment 12 Build Bot 2015-09-27 22:33:24 PDT
Comment on attachment 261998 [details]
Patch

Attachment 261998 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/219247

New failing tests:
svg/as-image/svg-cached-draw-canvas.html
Comment 13 Build Bot 2015-09-27 22:33:27 PDT
Created attachment 261999 [details]
Archive of layout-test-results from ews101 for mac-mavericks

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-mavericks  Platform: Mac OS X 10.9.5
Comment 14 Said Abou-Hallawa 2015-09-27 23:15:26 PDT
Created attachment 262000 [details]
Patch
Comment 15 Said Abou-Hallawa 2015-09-28 00:02:47 PDT
Created attachment 262002 [details]
test case
Comment 16 WebKit Commit Bot 2015-09-28 00:43:58 PDT
Comment on attachment 262000 [details]
Patch

Clearing flags on attachment: 262000

Committed r190274: <http://trac.webkit.org/changeset/190274>
Comment 17 WebKit Commit Bot 2015-09-28 00:44:03 PDT
All reviewed patches have been landed.  Closing bug.