Open
Bug 1367461
Opened 8 years ago
Updated 4 months ago
SVG background-images with preserveAspectRatio='none' render differently to Chrome/WebKit
Categories
(Core :: Layout: Images, Video, and HTML Frames, defect)
Core
Layout: Images, Video, and HTML Frames
Tracking
()
NEW
Webcompat Priority | P3 |
People
(Reporter: wisniewskit, Unassigned)
References
(Blocks 1 open bug, )
Details
(Keywords: webcompat:platform-bug, Whiteboard: webcompat)
Attachments
(4 files)
Chorme/WebKit appear to render SVG background-images with background-size:contain as Firefox does when background-size:100% 100% is used instead (that is, Firefox does not stretch them vertically the same way). Compare the attached testcase in both browsers for a quick example (note that Edge did not seem to render the SVG at all when I just tried it).
Flags: webcompat?
Reporter | ||
Comment 1•8 years ago
|
||
Actually, I'm unsure if it's specific to SVGs. I just tried replacing the data-url with a 2x2 pixel PNG and it might also be showing the same rendering-difference:
background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAFUlEQVQI1wXBAQEAAACAEP9PF1CpMCnkBftjnTYAAAAAAElFTkSuQmCC");
Reporter | ||
Comment 2•8 years ago
|
||
Jet, is this something we should triage soon?
Flags: needinfo?(bugs)
Reporter | ||
Comment 3•7 years ago
|
||
dholbert, what do you think about this one?
Flags: needinfo?(dholbert)
Comment 4•7 years ago
|
||
This seems interesting, though I'm not sure this has anything to do with "background-size:contain".
With the testcase as well as the original URL ( http://www.makeuseof.com/service/linux/ ), the rendering doesn't seem to be impacted by the "background-size:contain" styling. Neither Firefox nor Chrome change their behavior if I uncheck that style in devtools.
Maybe that's different depending on DPI or some other system metric, though -- could you confirm whether "background-size:contain" really makes a difference here?
Flags: needinfo?(dholbert) → needinfo?(wisniewskit)
Comment 5•7 years ago
|
||
Comment 6•7 years ago
|
||
Facts about testcase 2:
* We draw three short dark triangles on "testcase 2" (32px tall each).
* Chrome and Edge only draw one tall triangle (100px tall, the full height of the div).
* THOUGH: if I remove preserveAspectRatio='none' from the SVG image, then Edge & Chrome change to match us. (and our rendering doesn't change.) So it seems that attribute influences their calculation of the image's height, when they decide how to tile it.
The Chrome/Edge behavior seems odd to me -- IIRC preserveAspectRatio is only supposed to influence *whether* an image is stretched/skewed when rendered to a given viewport. And in this case, when preserveAspectRatio is omitted, Chrome/Edge seem to agree with us that the viewport for each image-repetition is only about 1/3 the height of the div. But they change their mind about the viewport size if preserveAspectRatio='none' is provided.
In other words: IIUC, preserveAspectRatio is only supposed to take effect *after* a viewport has been decided on (and then influences how the SVG content scales to fit that viewport). But in this case, Chrome/Edge seem to be letting it influence the actual decision about how big the viewport itself should be (or "viewports", really, since the image gets tiled).
https://www.w3.org/TR/SVG11/coords.html#PreserveAspectRatioAttribute
Anyway -- at this point, given just one known affected site and not super-serious breakage, I'm not inclined to worry about this too much, though perhaps we should file a Chrome/Edge bug (and perhaps find out via that bug if they have any spec justification for their behavior).
Reporter | ||
Comment 7•7 years ago
|
||
I agree with your assessment. Clearing the needinfo.
Flags: needinfo?(wisniewskit)
Updated•7 years ago
|
Flags: needinfo?(bugs)
Summary: SVG background-images with background-size:contain render differently to Chrome/WebKit → SVG background-images with preserveAspectRatio='none' render differently to Chrome/WebKit
Updated•7 years ago
|
Flags: webcompat?
Updated•6 years ago
|
Product: Core → Core Graveyard
Updated•6 years ago
|
Product: Core Graveyard → Core
Updated•3 years ago
|
Updated•3 years ago
|
Webcompat Priority: --- → ?
Updated•3 years ago
|
Webcompat Priority: ? → P3
Updated•2 years ago
|
Severity: normal → S3
For anyone who needs to scale an SVG mask in one dimension, a workaround is to inline the SVG like so...
elem {
mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg viewBox='0 0 1920 160' xmlns='http://www.w3.org/2000/svg' preserveAspectRatio='none'%3E %3Cpath d='M1925,165L-5,165L-5,128.941C-5,128.941 589.057,0 1068.81,0C1413.54,0 1758.26,47.987 1925,74.999L1925,165Z'/%3E %3C/svg%3E"); /* you need the viewbox set as well as preserveAspectRatio="none" */
mask-size: 100% 160px;
}
Comment 9•9 months ago
|
||
https://github.com/webcompat/web-bugs/issues/5411 has changed design and I don't see the issue anymore
https://github.com/webcompat/web-bugs/issues/85868 is still reproducible, I've moved it to bug1891075
Comment 10•9 months ago
|
||
I reduced another testcase from the current version of how this is reproducing on https://theflowerfarm.nl/ (for the "want to know more about palm oil" section, per bug 1891075 comment 0).
Here's the SVG that the site uses, for use in the testcase.
Comment 11•9 months ago
|
||
Updated•4 months ago
|
Keywords: webcompat:platform-bug
You need to log in
before you can comment on or make changes to this bug.
Description
•