SVG feColorMatrix gives wrong result on Display P3 screens

30 views
Skip to first unread message

Hans Otto Wirtz

unread,
Aug 26, 2024, 4:40:35 PM8/26/24
to paint-dev
Hi,

I'm Hans Otto from BubblyDoo. We create personalize d products and rely heavily on SVG feColorMatrix to do so. For a couple of years now we've had a problem with feColorMatrix on Chrome on Macbook screens, as they are Display P3 screens.

Basically, it seems that the filter is using the Display P3 color space as the interpolation space instead of using sRGB.

And a small analysis and workaround here: https://chromium-fecolormatrix-bug-analysis.vercel.app/

I had a couple of questions:
- Is this a bug in Chrome, or is this the intended result? Is the spec ambiguous?
- Could I contribute to fixing it in some way? If so, could I get some pointers to where I should start?

Best regards,
Hans Otto Wirtz

Hans Otto Wirtz

unread,
Aug 27, 2024, 5:25:40 PM8/27/24
to paint-dev, Hans Otto Wirtz

Fredrik Söderquist

unread,
Aug 27, 2024, 5:25:49 PM8/27/24
to Hans Otto Wirtz, paint-dev
On Mon, Aug 26, 2024 at 10:40 PM Hans Otto Wirtz <hansot...@gmail.com> wrote:
Hi,

I'm Hans Otto from BubblyDoo. We create personalize d products and rely heavily on SVG feColorMatrix to do so. For a couple of years now we've had a problem with feColorMatrix on Chrome on Macbook screens, as they are Display P3 screens.

Basically, it seems that the filter is using the Display P3 color space as the interpolation space instead of using sRGB.

And a small analysis and workaround here: https://chromium-fecolormatrix-bug-analysis.vercel.app/

I had a couple of questions:
- Is this a bug in Chrome, or is this the intended result? Is the spec ambiguous?

This is probably one of those stories that start with "Because of historical reasons...". AFAICR, the implementation started out as essentially being "device RGB" (most commonly sRGB at that time), and then that has mostly lived on until today. Similarly, when the spec was written 20+ years ago there weren't many color spaces to consider. The spec doesn't speak all that much about color spaces, but it does spell out sRGB (or linear-light sRGB) as the interpolation space(s). So I'd think it's a bug (thanks for filing one!). The code itself is probably a bit mixed in what the output will be - because of how the color interpolation space is handled (which is by adding additional nodes in the filter graph when "needed"). So I think that mileage may vary wrt if the input will end up being "color space transformed" at all.
 
- Could I contribute to fixing it in some way? If so, could I get some pointers to where I should start?

For feColorMatrix, the place to start would be FEColorMatrix::CreateImageFilter() [1], but I suspect the main problem will be figure out how this will integrate (or not, most likely) with the current color interpolation handling. I'd be happy to be a sounding board for that part.


/fs

 

Best regards,
Hans Otto Wirtz

--
You received this message because you are subscribed to the Google Groups "paint-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to paint-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/paint-dev/97d3a141-4998-4232-9b03-041cd0429e8an%40chromium.org.
Reply all
Reply to author
Forward
0 new messages