lume / kiwi

Fast TypeScript implementation of the Cassowary constraint solving algorithm (soon for AssemblyScript / WebAssembly).
https://codepen.io/trusktr/pen/abMLVxa
Other
149 stars 8 forks source link

Fix hanging optimize function #2

Closed kretz closed 2 years ago

kretz commented 2 years ago

Limit the number of iterations allowed in optimize so as not to hang. Throw error if exceeded.

trusktr commented 2 years ago

Nice, looks like a good idea. Is 10,000 a good number? Seems like by that many iterations something is definitely not great in the constraints. Merging, and we could always revisit the number.

kretz commented 2 years ago

Not sure in general. I found that 10000 is high. Had some problematic constraints run up to 2000 and then end up in being "unbounded". But normal operation is below 10.

The main point for me was that it is a bailout if something goes wrong, so it will not hang.

kretz commented 2 years ago

@trusktr Is there a chance of getting a patch version of the package deployed? Anything I can help with?