Bug 225120

Summary: SVG filter is applied twice when applied to the root <svg> element
Product: WebKit Reporter: Xiaolong Li <lxlstudent>
Component: SVGAssignee: Kiet Ho <kiet.ho>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, kiet.ho, sabouhallawa, simon.fraser, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: Safari 14   
Hardware: Mac (Intel)   
OS: macOS 11   
URL: https://codepen.io/xiaolong-li/pen/YzNMZpM
See Also: https://bugs.webkit.org/show_bug.cgi?id=260152
https://bugs.webkit.org/show_bug.cgi?id=265465
Bug Depends on:    
Bug Blocks: 260152, 262180    
Attachments:
Description Flags
reduced test case none

Description Xiaolong Li 2021-04-27 13:19:51 PDT
The issue happens when defining a filter inside an <svg> element and directly reference/apply it on the <svg> element itself. In this case, Safari seems to "over-apply" the effect, and one guess is that it may have applied the effect twice.

This issue doesn't appear in Chrome or Firefox. I also checked SVG spec and this is a legal structure.

If I move the filter attribute to a sub-element of the <svg>, then it works correctly.

Here is an example in CodePen demonstrating this. Opening it in Safari/Firefox/Chrome to see the difference: https://codepen.io/xiaolong-li/pen/YzNMZpM

I found an existing bug (https://bugs.webkit.org/show_bug.cgi?id=139281) that may be related to this, but not sure.
Comment 1 Radar WebKit Bug Importer 2021-05-04 13:20:15 PDT
<rdar://problem/77522728>
Comment 2 Said Abou-Hallawa 2023-06-06 13:21:08 PDT
This is correct. When the SVGFilter is applied to the <svg> root element, it is applied as an SVGFilter and it is also applied as CSSFilter referencing this SVGFilter.
Comment 3 Said Abou-Hallawa 2023-06-06 13:22:04 PDT
Created attachment 466605 [details]
reduced test case
Comment 4 Kiet Ho 2023-06-08 11:22:18 PDT
Pull request: https://github.com/WebKit/WebKit/pull/14780
Comment 5 EWS 2023-06-13 14:26:57 PDT
Committed 265135@main (0dac14ca10cb): <https://commits.webkit.org/265135@main>

Reviewed commits have been landed. Closing PR #14780 and removing active labels.
Comment 6 Kiet Ho 2023-06-13 23:42:09 PDT
*** Bug 139281 has been marked as a duplicate of this bug. ***