Bug 191197 - SVG filters crash on iOS and are slow in general
Summary: SVG filters crash on iOS and are slow in general
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: SVG (show other bugs)
Version: Safari 12
Hardware: All All
: P2 Major
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2018-11-02 10:23 PDT by Jan Bösenberg
Modified: 2022-02-16 05:27 PST (History)
6 users (show)

See Also:


Attachments
Test case for filter performance (1.50 KB, text/html)
2018-11-02 10:23 PDT, Jan Bösenberg
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Bösenberg 2018-11-02 10:23:53 PDT
Created attachment 353709 [details]
Test case for filter performance

A simple SVG using filters may crash on Safari iOS and is very slow.

To reproduce the issue open the attached test case or follow this link:   https://codepen.io/anon/pen/eQOxKE

With each cycle the test adds a clone of an SVG to the document. The SVG consists of a rect which has a filter applied.

It crashes after ~10 cycles on iPhone 4s, ~35 cycles on iPhone X and ~80 cycles on iPhone SE. On Safari desktop it is easily five times slower than Chrome, maybe comparable to Internet Explorer 11.

More notes:
- The same problem occurs if one SVG is created with multiple filtered rect elements, even if the same filter is applied to all elements.
- It does not matter what the filter does, even an empty filter containing only <feOffset /> gives the same result.
- I could not reproduce the crash with masks, so there seems to be a difference (although better performance on masks would not hurt)
Comment 1 Radar WebKit Bug Importer 2018-11-03 16:38:13 PDT
<rdar://problem/45787332>
Comment 2 Jan Bösenberg 2018-11-04 02:27:20 PST
For filters on monochrome rectangles (like in the example) where all pixels are manipulated the same (feColorMatrix, feComponentTransfer, etc), setting filterRes="1" will speed up things dramatically (by a factor 20 or so) and prevent the crashing.

Here is a modified version with filterRes set to 1:
https://codepen.io/anon/pen/LXYKJK

Unfortunately filterRes is obsolete in SVG2 and will be removed in the next Safari version (see bug 129565), so there will be no solution left. It's probably futile but I would suggest to keep support for filterRes in Safari until the performance issues with SVG filters are solved.