canvas.drawImage() doesn’t render SVG with clip-path and mix-blend-mode as expected
Categories
(Core :: Graphics: Canvas2D, defect)
Tracking
()
People
(Reporter: account-bugzilla, Assigned: lsalzman)
References
(Blocks 1 open bug, Regression)
Details
(Keywords: regression)
Attachments
(7 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36
Steps to reproduce:
Load an SVG image with an <img /> tag. The loaded SVG contains a clip-path that is applied to a group. Inside the group, there is an image element that is rendered with a mix-blend-mode.
- USerAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
- Browser: Firefox 135.0.1
- Operating System: Mac OS 15.3 (24D60)
- Hardware: Apple M3 Pro
Actual results:
When using this SVG image and rendering it on a canvas with drawImage(), the offset of the clip-path to the right and bottom is displayed as a stretched image.
Expected results:
The result of drawImage() should render the image on the canvas exactly as the original image.
The screenshot shows the actual rendering issue in Firefox. At the top, there is an <img>
element that loads the SVG. This image is then used to call drawImage()
on the <canvas>
element, which is rendered at the bottom.
![]() |
||
Updated•20 days ago
|
![]() |
||
Comment 2•20 days ago
|
||
I can reproduce on Nightly137.0a1 Windows11.
Regression window:
https://hg.mozilla.org/integration/autoland/pushloghtml?fromchange=affc4eac7db07097c3b16a9059a64e2cc1710d40&tochange=fe10049200dfa92f958f65b9fc37fef345694b41
![]() |
||
Updated•20 days ago
|
Comment 3•20 days ago
|
||
Set release status flags based on info from the regressing bug 1910138
:lsalzman, since you are the author of the regressor, bug 1910138, could you take a look? Also, could you set the severity field?
For more information, please visit BugBot documentation.
Assignee | ||
Comment 4•20 days ago
|
||
Timothy, this seems like a bug in SVG rendering.
Assignee | ||
Comment 5•19 days ago
|
||
Updated•19 days ago
|
I need to clarify my description of the bug. After further testing, I’ve realized that it is not related to clip-path. Instead, it is specifically caused by mix-blend-mode applied to a group. As a result, the actual positions of the objects inside the group are lost, causing them to shift to the coordinate origin (top/left = 0,0). This leads to an offset on the bottom/right, appearing as a glitch/distortion. I will add an other example...
The left side shows the SVG loaded into an <img>
, while the right side displays the SVG rendered on a <canvas>
using canvasContext2d.drawImage()
.
Updated•19 days ago
|
Comment 9•19 days ago
|
||
This has presumably affected Linux and Mac since bug 1806058.
Comment 10•18 days ago
|
||
Comment 11•18 days ago
|
||
bugherder |
Comment 12•18 days ago
|
||
The patch landed in nightly and beta is affected.
:lsalzman, is this bug important enough to require an uplift?
- If yes, please nominate the patch for beta approval.
- If no, please set
status-firefox136
towontfix
.
For more information, please visit BugBot documentation.
Reporter | ||
Comment 13•17 days ago
|
||
Reporter | ||
Comment 14•17 days ago
|
||
:smolnar, I've tested the nightly build 137.0a1 (2025-02-26) with my attached file Archive2.zip. The positioning works fine, but there is still a glitch with on the border of the shape... see screenshot
Assignee | ||
Comment 15•16 days ago
|
||
For offset surfaces, the source rect to DrawSurface may not actually be entirely filled by
the surface's contents. In this case, we need to clip the source and dest rects to reflect
the actual surface content bounds.
This required some collateral modifications to make using offset surfaces safe in a few other
places in DrawTargets in general.
Updated•16 days ago
|
Comment 16•16 days ago
|
||
Updated•15 days ago
|
Comment 17•15 days ago
|
||
bugherder |
Updated•11 days ago
|
Description
•