Bug 256791

Summary: [svg] contrast() filter does not affect SVG elements
Product: WebKit Reporter: Mark Eriksson <markeriksson94>
Component: SVGAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: dino, graouts, graouts, sabouhallawa, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: Safari 16   
Hardware: iPhone / iPad   
OS: iOS 16   
Attachments:
Description Flags
Reduction none

Description Mark Eriksson 2023-05-15 09:38:46 PDT
I am animating the CSS filter property via the JS Web Animation API and Safari on iOS 16 is not applying the animations.
If I change the animation to use something like opacity, it applies, so there must be an issue with the filter property.

Code:
el.animate([{ filter: "contrast(150%)" }, { filter: "contrast(175%)" }], {
  duration: 200,
});

However, if I change to:
el.animate([{ opacity: 0.5 }, { opacity: 0.8 }], {
  duration: 200,
});
...it works fine.
Comment 1 Mark Eriksson 2023-05-16 02:57:49 PDT
FYI, it is probably worth mentioning that the element I am animating is an SVG <path> element. If I try the animation on any element that isn't an SVG <path> element (<img> for example), it works.
Comment 2 Antoine Quint 2023-05-22 01:17:47 PDT
Mark, could you write a test that shows the issue and attach it? This would help.
Comment 3 Mark Eriksson 2023-05-22 02:44:00 PDT
(In reply to Antoine Quint from comment #2)
> Mark, could you write a test that shows the issue and attach it? This would
> help.

Hi Antoine, yes; is there a guideline/convention for writing tests you have that I should follow?
Comment 4 Mark Eriksson 2023-05-22 03:21:47 PDT
Here is a link to a demo of the issue, best demonstrated on iOS Safari.

https://codepen.io/Markshall/pen/oNaJozr

As you can see, scrubbing your finger over the 'filter'-animated SVG renders no change, however the 'opacity'-animated SVG renders the animation.
Comment 5 Radar WebKit Bug Importer 2023-05-22 09:39:32 PDT
<rdar://problem/109663447>
Comment 6 Antoine Quint 2023-07-11 00:07:10 PDT
To make the example work in Safari on macOS, you must change this TypeScript line:

    if (e instanceof TouchEvent)

to:

    if ('TouchEvent' in window && e instanceof TouchEvent)

I've tried this example in older versions of Safari and it seems to never have worked, so this is not a regression.
Comment 7 Antoine Quint 2023-07-11 05:32:34 PDT
Created attachment 467022 [details]
Reduction

This has nothing to do with animations. The issue is that the `contrast()` filter function does not work on an SVG element as shown in the attached reduction. This works fine with an HTML element.