Skip to content

Limit the curves of an elliptical arc with a huge radius - #74

Open
josefguenther wants to merge 1 commit into
linebender:mainfrom
josefguenther:fix/arc-cubic-count
Open

josefguenther wants to merge 1 commit into
linebender:mainfrom
josefguenther:fix/arc-cubic-count

Conversation

@josefguenther

@josefguenther josefguenther commented Nov 1, 2026 •

Copy link
Copy Markdown

An arc with a huge radius never finishes converting: M 21 15 a 2 2 0 0 1 2e50 2 runs until it fills the memory. Arcs are converted to cubics at a fixed tolerance of 0.1, so the number of cubics grows with the radius.

This scales the tolerance with the radius once it's past 100,000 (to 1e-6 of the larger radius). Smaller arcs are unchanged, and no arc takes more than 11 cubics a full turn.

Arc Cubics before Cubics after
Quarter circle, radius 1e4 2 2
Quarter circle, radius 1e7 6 3
Quarter circle, radius 1e20 806 3
Quarter circle, radius 1e40 not finished after 3 s 3
Radius 2, ending 2e50 away not finished after 3 s 6

The code in this PR is substantially LLM generated (Claude Code); I have reviewed it.

@Its-Just-Nans

Copy link
Copy Markdown
Contributor

Hi

I think you should try to create an MR on https://github.com/linebender/resvg/tree/main/crates/svgtypes (the repository was moved)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants