You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SVG picture markers: a large style sheet takes tens of seconds to read #2800
I searched the existing issues and did not find a duplicate.
This is a bug report, not a usage question.
What happened?
An SVG marker image (#2266, #2704) with a large <style> sheet, or a style attribute with many declarations, keeps the command that sets it busy for many seconds, and the app with it. The SVG's bounds (crates/render/src/picture/svg.rs) don't cover it, because the time goes into parsing the sheet itself, before any count.
usvg parses style sheets and style attributes with simplecss 0.2.2. Each declaration's value ends with an identifier read that fails (consume_term, lib.rs:550). That error works out its row and column by scanning the text from the start (Stream::gen_text_pos_from, stream.rs:199, and calc_curr_row, stream.rs:281), so each declaration costs as much as its position, and a sheet costs the square of its declarations. Measured, in a dev build with dependencies at opt-level 2:
Sheet
Bytes
Time
10,000 rules .cN { fill: red }
199 KB
0.64 s
20,000 rules
409 KB
2.5 s
40,000 rules
829 KB
10.5 s
one rule of 20,000 declarations
220 KB
1.4 s
a 400 KB comment and one rule
400 KB
0.4 ms
A marker image may hold up to 1.5 MiB of SVG, about 75,000 such rules: some 37 s at this rate.
Steps to reproduce
Make an SVG whose <style> holds 40,000 rules (.c0 { fill: red } .c1 { fill: red } …) and one <rect>.
Run layer.marker {"layer": "Cities", "image": "<the SVG as base64>"} in the Script pane, on the World Atlas sample.
Expected behavior
An SVG whose style sheets take too long to read is refused quickly, like one with too much to draw (#2713), and never reaches the reader. For example, refuse a sheet or style attribute whose declarations times its length passes a cap measured at about 15 ms, before usvg reads it.
Taking this one: the fix is in #3030, two bounds checked before simplecss and roxmltree read the SVG (style text and element attributes), refused with their own cause in the marker notice.
Activity
fix(render): an SVG entity that holds a tag is refused before reading…
jgregoriorincon commentedon Nov 26, 2026
Taking this one: the fix is in #3030, two bounds checked before simplecss and roxmltree read the SVG (style text and element attributes), refused with their own cause in the marker notice.
fix(render): an SVG entity of a tag is refused as too much to read, a…
fix(render): reading an SVG's style text and element attributes is bo…