Bug 225120 - SVG filter is applied twice when applied to the root <svg> element
Summary: SVG filter is applied twice when applied to the root <svg> element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari 14
Hardware: Mac (Intel) macOS 11
: P2 Normal
Assignee: Kiet Ho
URL: https://codepen.io/xiaolong-li/pen/Yz...
Keywords: InRadar
: 139281 (view as bug list)
Depends on:
Blocks: 260152 262180
  Show dependency treegraph
 
Reported: 2021-04-27 13:19 PDT by Xiaolong Li
Modified: 2023-11-29 12:22 PST (History)
6 users (show)

See Also:


Attachments
reduced test case (537 bytes, text/html)
2023-06-06 13:22 PDT, Said Abou-Hallawa
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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. ***