-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Crash on svg optimization #2075
Comments
That is the largest SVG I've ever seen I find it unlikely that SVGO would be able to efficiently handle this SVG at any point, so if I were you I would:
|
hi @KTibow , Thanks for your reply! I really appreciate everything the SVGO library provides. This is why I asked about the possibility of adding a timeout configuration. Do you have any additional suggestions for avoiding situations like this? Thanks in advance! |
Why not only run optimization on small files or implement the timeout inside whatever program is falling SVGO |
I’d like to try a timeout solution, but it seems that once optimization starts on such a large input, SVGO quickly consumes CPU resources, leading to server crashes. Perhaps the simplest solution would be to just limit the size of uploaded SVGs. |
Try disabling mergePaths–it has some some complicated logic to check for intersections which may be too much for your case. |
This doesn't have much to do with the file size. SVGO doesn't handle styles efficiently, and this file has about 8500 style rules. I've been looking into some of the scalability problems with SVGO, and working on a version that handles this better - https://www.npmjs.com/package/svgo-ll. It still takes almost a minute on a not particularly fast laptop. Almost all of the time is spent inlining the styles, other than that it's pretty fast. The inlining could be sped up significantly for this file, but it may be enough of a special case that it's not worth it. Compression on the current version is 22.7%. |
@johnkenny54 Thanks for your feedback! This particular SVG comes from one of our clients and is one of the most complex we've dealt with so far. Since then, we've implemented a file size limit for SVGs (up to 1.5MB) to keep things running smoothly. If SVGO2 has stable releases, we'll definitely run some benchmarks later! |
node: 20.10.0
svgo: 3.3.2
Hi
We've encountered an issue while using SVGO to optimize SVG inputs. In the following case, the optimization function hangs, causing really high CPU usage and eventually leading the server to crash after some time.
Through step-by-step debugging, we identified a set of plugins that take an unusually long time to run, effectively blocking the entire process (marked as '// too long' in the code snippet below).
Could someone offer any advice on this please?
A more general question related to this issue: is there a way to implement a timeout mechanism to abort the process if it takes too long, and eventually release the occupied resources?
Thanks a lot!
The text was updated successfully, but these errors were encountered: