ssssota / svg2png-wasm

SVG to PNG converter JS library made with WASM + resvg (no native dependencies).
https://ssssota.github.io/svg2png-wasm/
MIT License
152 stars 10 forks source link

Improve rendering performance #39

Open yisibl opened 2 years ago

yisibl commented 2 years ago

For example, this file renders very slowly: https://commons.wikimedia.org/wiki/File:Anime_Girl.svg

Improvements: https://github.com/yisibl/resvg-js/blob/443d1c3de7cf2dc72c87299cb046e57621062654/Cargo.toml#L29-L34 This increases the size of the wasm file, but it improves rendering performance to some extent, and I think it's worth it.

Fundamentally, it may require upstream resvg to optimize.

ssssota commented 2 years ago

@yisibl I tried changing the build option. There was indeed a slight speedup, but the conversion of Anime_Girl.svg is still significantly slower than resvg-js.

I will publish #44 , but I'm going to keep this issue open and proceed with the research.

yisibl commented 2 years ago

Yes, it's actually unfair to compare wasm with a library that generates binaries like resvg-js, wasm itself will have some overhead.

As a wasm library, we can just make a compromise between performance and file size.

OpenGG commented 2 years ago

The original svg takes forever to render with wasm. Not even possible to get a valid timeline profiling report.

I had to make smaller width/height:

viewBox="0 0 744 1052" height="100" width="142"

Timeline shows major cost in resvg::render::render_node and resvg::render::render_group.

timeline

timeline.tar.gz