Skip to content
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

Error: infinite loop while processing mergePaths plugin. #987

Closed
JoKalliauer opened this issue Jun 22, 2018 · 4 comments
Closed

Error: infinite loop while processing mergePaths plugin. #987

JoKalliauer opened this issue Jun 22, 2018 · 4 comments

Comments

@JoKalliauer
Copy link

JoKalliauer commented Jun 22, 2018

Prozessing File:Pereslavl_narrow_gauge_railway_1990.svg with

svgo -i Pereslavl_narrow_gauge_railway_1990.svg -o output.svg --pretty --indent=1 --disable=convertPathData

leads to

Error: infinite loop while processing mergePaths plugin.


input.svg.txt
input


output.svg.txt
output

@GreLI
Copy link
Member

GreLI commented Jun 23, 2018

There is a fixed limit to prevent infinite loop. Perhaps file is just too large. Generally I'd recommend to disable mergePaths on a such big files. (Should make an option to force.)

@JoKalliauer
Copy link
Author

I see it the other way round.

For small files (source-code fits on ~one screen) svgoptimizers are useful to make the code better readable. Merging Path might be unwanted, because they might be two different objects, and after merging it is difficult to find the right part of the source-code.

For big files (~30MB, f.e Category:Large_SVG_files) svgoptimizers can be used to reduce the file-size. mergePath is therefore a useful tool. (Also it leads to long processing times.)
Reducing file-size might be necessary to be able to create a png or to render in a browser.

In Jan.2018 I used this tool to merge 483840 lines in File:1_42_polytope_7-cube.svg to one path. and I did not get such an error-messages. (Maybe there was an update between?)

@JoKalliauer
Copy link
Author

I shortend the example just to two pathes:

I used:

svgo -i input.svg.txt -o output.svg --pretty --indent=1 --disable=convertPathData -p 10

and I still get the error:
Error: infinite loop while processing mergePaths plugin.


input.svg.txt

<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:cc="http://creativecommons.org/ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" width="840.99mm" height="345.1mm" fill="none" fill-rule="evenodd" stroke="#000" stroke-linecap="square" stroke-linejoin="bevel" version="1.1" viewBox="0 0 9933 4076">
  <g stroke-width="11.81" fill="#000" fill-rule="nonzero" stroke="#fff">
   <path d="m4948.6 1499.9c0 1.23-.232 2.31-.697 3.237-.465.93-1.09 1.7-1.876 2.308-.93.73-1.95 1.25-3.063 1.561-1.11.31-2.53.465-4.242.465h-9.895v-24.72h8.733c1.82 0 3.19.069 4.126.208.935.138 1.81.429 2.631.872.885.476 1.55 1.11 1.984 1.909.437.797.656 1.72.656 2.756 0 1.21-.302 2.28-.905 3.221s-1.44 1.63-2.499 2.075v.133c1.53.321 2.75.977 3.669 1.967.919.991 1.38 2.33 1.378 4.009m-7.952-10.16c0-.398-.102-.808-.307-1.229s-.523-.725-.955-.913c-.41-.177-.894-.274-1.453-.291s-1.39-.025-2.499-.025h-.432v5.23h.78c1.06 0 1.81-.011 2.233-.033s.866-.138 1.32-.349c.498-.232.841-.553 1.029-.963s.282-.886.282-1.428m1.561 10.044c0-.764-.155-1.36-.465-1.793s-.775-.758-1.395-.98c-.376-.144-.894-.224-1.552-.241s-1.54-.025-2.648-.025h-1.146v6.192h.332c1.62 0 2.73-.011 3.354-.033s1.25-.172 1.893-.448c.564-.243.977-.6 1.237-1.071.26-.47.39-1 .39-1.602m18.833 8.185c-3.52 0-6.22-.841-8.093-2.523-1.88-1.68-2.81-4.08-2.814-7.189 0-3.04.874-5.47 2.623-7.288 1.75-1.82 4.19-2.72 7.338-2.723 2.86 0 5 .769 6.441 2.308s2.16 3.74 2.158 6.607v2.092h-12.733c.055.863.238 1.59.548 2.167a3.8 3.8 0 001.229 1.386c.498.343 1.08.589 1.743.739a9.94 9.94 0 002.175.224 8.92 8.92 0 001.992-.224 9.618 9.618 0 001.793-.589 12.934 12.934 0 002.308-1.328h.614v4.798c-.476.188-.91.362-1.303.523s-.932.324-1.619.49c-.631.166-1.28.296-1.951.39-.67.094-1.49.141-2.449.141m1.926-12.219c-.033-1.23-.318-2.16-.855-2.806-.537-.642-1.36-.963-2.465-.963-1.13 0-2.01.338-2.648 1.013-.636.675-.988 1.59-1.054 2.756zm3.304-9.579h-4.765v-4.532h4.765zm-7.985 0h-4.765v-4.532h4.765zm31.621 21.3h-6.69l-4.416-7.388h-1.494v7.388h-5.811v-18.644h5.811v7.487c.819-.011 1.43-.13 1.834-.357s.844-.827 1.32-1.801c.155-.332.321-.697.498-1.096.177-.398.338-.753.481-1.063.587-1.23 1.31-2.07 2.167-2.523.858-.454 1.9-.681 3.129-.681.432 0 .841.006 1.229.017.387.011.664.017.83.017v4.981h-1.129c-.354 0-.672.069-.955.208a2.756 2.756 0 00-.739.523c-.21.221-.368.443-.473.664l-.307.648a39.53 39.53 0 01-.565 1.278c-.122.255-.338.504-.647.747zm11.736.498c-1.54 0-2.95-.194-4.225-.581s-2.39-.985-3.329-1.793c-.93-.808-1.65-1.82-2.175-3.046-.52-1.22-.78-2.66-.78-4.325 0-1.78.282-3.3.847-4.549.564-1.25 1.33-2.28 2.291-3.088.93-.775 2.02-1.35 3.279-1.718 1.26-.371 2.56-.556 3.926-.556 1.03 0 2.06.119 3.088.357 1.03.238 2.06.617 3.105 1.137v4.981h-.747c-.232-.221-.517-.465-.855-.731s-.706-.509-1.104-.73a7.315 7.315 0 00-1.428-.589 6.128 6.128 0 00-1.776-.241c-1.48 0-2.63.517-3.445 1.552-.814 1.03-1.22 2.43-1.22 4.175 0 1.87.434 3.26 1.303 4.184.869.919 2.02 1.38 3.461 1.378.73 0 1.37-.083 1.926-.249s1.03-.365 1.428-.598c.387-.232.719-.473.996-.722s.515-.473.714-.672h.747v4.981l-1.154.498a9.881 9.881 0 01-1.336.465c-.564.155-1.09.274-1.585.357-.493.083-1.14.125-1.951.125m19.129-5.362v-3.885c-.985.1-1.78.185-2.391.257a8.09 8.09 0 00-1.793.423c-.509.177-.905.445-1.187.805s-.423.838-.423 1.436c0 .874.235 1.47.706 1.801s1.16.49 2.084.49c.509 0 1.03-.116 1.561-.349a4.869 4.869 0 001.444-.979m0 2.889-1.071.896c-.316.266-.739.531-1.27.797-.52.255-1.03.448-1.519.581s-1.18.199-2.067.199c-1.65 0-3.02-.553-4.109-1.66-1.09-1.11-1.64-2.5-1.635-4.184 0-1.38.277-2.5.83-3.354.553-.852 1.35-1.53 2.391-2.025 1.05-.509 2.31-.863 3.769-1.063 1.46-.199 3.03-.354 4.715-.465v-.1c0-1.03-.379-1.74-1.137-2.133s-1.9-.589-3.412-.589c-.686 0-1.49.124-2.407.374s-1.82.567-2.689.955h-.498v-4.499c.576-.166 1.51-.362 2.789-.589 1.28-.227 2.58-.34 3.885-.34 3.21 0 5.55.534 7.014 1.602 1.47 1.07 2.2 2.7 2.199 4.889v12.684h-5.777z"/>
   <path d="m4949.5 1522.8-8.5 24.72h-6.475l-8.5-24.72h6.441l5.379 16.751 5.379-16.751zm19.414 6.076-9.413 25.483h-6.242l2.822-7.288-6.84-18.195h6.109l3.918 11.688 3.669-11.688zm20.498 9.33c0 3.07-.838 5.48-2.515 7.247-1.68 1.77-4.05 2.65-7.114 2.648-3.04 0-5.41-.883-7.097-2.648-1.69-1.77-2.53-4.18-2.532-7.247 0-3.1.844-5.53 2.532-7.28 1.69-1.75 4.05-2.63 7.097-2.631 3.05 0 5.42.883 7.106 2.648 1.68 1.77 2.52 4.19 2.523 7.263m-5.96.033c0-1.11-.091-2.03-.274-2.764s-.434-1.33-.755-1.768c-.343-.465-.73-.789-1.162-.971-.432-.183-.924-.274-1.478-.274-.52 0-.991.08-1.411.241-.421.16-.808.468-1.162.921-.332.432-.598 1.02-.797 1.776s-.299 1.7-.299 2.839c0 1.14.094 2.06.282 2.764.188.703.432 1.26.73 1.685.31.432.697.747 1.162.946s.98.299 1.544.299c.465 0 .938-.1 1.419-.299a2.628 2.628 0 001.154-.896c.343-.476.603-1.05.78-1.718s.266-1.6.266-2.781m27.724 9.28h-6.906l-5.047-8.118-.896 1.212v6.906h-5.811v-25.832h5.811v14.476l5.512-7.288h6.856l-6.524 8.035zm7.018.515c-1.37 0-2.67-.149-3.893-.448-1.22-.299-2.23-.647-3.03-1.046v-4.914h.481c.277.21.592.443.946.697.354.255.847.52 1.478.797.542.255 1.15.473 1.834.656a8.52 8.52 0 002.216.274c.819 0 1.54-.127 2.167-.382.625-.255.938-.659.938-1.212 0-.432-.144-.758-.432-.979s-.847-.432-1.677-.631c-.443-.111-1-.23-1.677-.357s-1.27-.274-1.793-.44c-1.46-.454-2.56-1.13-3.295-2.017-.736-.891-1.1-2.06-1.104-3.511 0-.83.191-1.61.573-2.349.382-.736.944-1.39 1.685-1.967.742-.564 1.66-1.01 2.748-1.345 1.09-.332 2.32-.498 3.694-.498 1.31 0 2.51.13 3.603.39s2.02.573 2.773.938v4.715h-.465a10.648 10.648 0 00-.946-.623c-.432-.26-.852-.484-1.262-.672-.487-.221-1.03-.404-1.635-.548s-1.22-.216-1.851-.216c-.841 0-1.55.144-2.133.432-.581.288-.872.67-.872 1.146 0 .421.144.753.432.996s.913.482 1.876.714c.498.122 1.07.241 1.718.357s1.27.274 1.868.473c1.34.432 2.35 1.07 3.046 1.901.691.836 1.04 1.95 1.037 3.329 0 .874-.205 1.71-.614 2.499a5.64 5.64 0 01-1.743 2.001c-.797.587-1.73 1.04-2.814 1.361-1.08.321-2.37.481-3.877.481m22.599-5.379v-3.885c-.985.1-1.78.185-2.391.257a8.104 8.104 0 00-1.793.423c-.509.177-.904.445-1.187.805-.282.36-.423.838-.423 1.436 0 .874.235 1.47.706 1.801.47.326 1.16.49 2.083.49.509 0 1.03-.116 1.561-.349a4.869 4.869 0 001.444-.979m0 2.889-1.071.896c-.315.266-.739.531-1.27.797a8.58 8.58 0 01-1.519.581c-.492.133-1.18.199-2.067.199-1.65 0-3.02-.553-4.109-1.66-1.09-1.11-1.64-2.5-1.635-4.184 0-1.38.277-2.5.83-3.354.554-.852 1.35-1.53 2.391-2.025 1.05-.509 2.31-.863 3.768-1.063s3.03-.354 4.715-.465v-.1c0-1.03-.379-1.74-1.137-2.133s-1.9-.589-3.412-.589c-.686 0-1.49.124-2.407.374-.918.249-1.82.567-2.689.955h-.498v-4.499c.575-.166 1.5-.362 2.789-.589s2.58-.34 3.884-.34c3.21 0 5.55.534 7.015 1.602 1.47 1.07 2.2 2.7 2.199 4.889v12.684h-5.777z"/>
  </g>
</svg>

output.svg.txt

<svg xmlns="http://www.w3.org/2000/svg" width="840.99mm" height="345.1mm" fill="none" fill-rule="evenodd" stroke="#000" stroke-linecap="square" stroke-linejoin="bevel" viewBox="0 0 9933 4076">
 <g stroke-width="11.81" fill="#000" fill-rule="nonzero" stroke="#fff">
  <path d="m4948.6 1499.9c0 1.23-.232 2.31-.697 3.237-.465.93-1.09 1.7-1.876 2.308-.93.73-1.95 1.25-3.063 1.561-1.11.31-2.53.465-4.242.465h-9.895v-24.72h8.733c1.82 0 3.19.069 4.126.208.935.138 1.81.429 2.631.872.885.476 1.55 1.11 1.984 1.909.437.797.656 1.72.656 2.756 0 1.21-.302 2.28-.905 3.221s-1.44 1.63-2.499 2.075v.133c1.53.321 2.75.977 3.669 1.967.919.991 1.38 2.33 1.378 4.009m-7.952-10.16c0-.398-.102-.808-.307-1.229s-.523-.725-.955-.913c-.41-.177-.894-.274-1.453-.291s-1.39-.025-2.499-.025h-.432v5.23h.78c1.06 0 1.81-.011 2.233-.033s.866-.138 1.32-.349c.498-.232.841-.553 1.029-.963s.282-.886.282-1.428m1.561 10.044c0-.764-.155-1.36-.465-1.793s-.775-.758-1.395-.98c-.376-.144-.894-.224-1.552-.241s-1.54-.025-2.648-.025h-1.146v6.192h.332c1.62 0 2.73-.011 3.354-.033s1.25-.172 1.893-.448c.564-.243.977-.6 1.237-1.071.26-.47.39-1 .39-1.602m18.833 8.185c-3.52 0-6.22-.841-8.093-2.523-1.88-1.68-2.81-4.08-2.814-7.189 0-3.04.874-5.47 2.623-7.288 1.75-1.82 4.19-2.72 7.338-2.723 2.86 0 5 .769 6.441 2.308s2.16 3.74 2.158 6.607v2.092h-12.733c.055.863.238 1.59.548 2.167a3.8 3.8 0 001.229 1.386c.498.343 1.08.589 1.743.739a9.94 9.94 0 002.175.224 8.92 8.92 0 001.992-.224 9.618 9.618 0 001.793-.589 12.934 12.934 0 002.308-1.328h.614v4.798c-.476.188-.91.362-1.303.523s-.932.324-1.619.49c-.631.166-1.28.296-1.951.39-.67.094-1.49.141-2.449.141m1.926-12.219c-.033-1.23-.318-2.16-.855-2.806-.537-.642-1.36-.963-2.465-.963-1.13 0-2.01.338-2.648 1.013-.636.675-.988 1.59-1.054 2.756zm3.304-9.579h-4.765v-4.532h4.765zm-7.985 0h-4.765v-4.532h4.765zm31.621 21.3h-6.69l-4.416-7.388h-1.494v7.388h-5.811v-18.644h5.811v7.487c.819-.011 1.43-.13 1.834-.357s.844-.827 1.32-1.801c.155-.332.321-.697.498-1.096.177-.398.338-.753.481-1.063.587-1.23 1.31-2.07 2.167-2.523.858-.454 1.9-.681 3.129-.681.432 0 .841.006 1.229.017.387.011.664.017.83.017v4.981h-1.129c-.354 0-.672.069-.955.208a2.756 2.756 0 00-.739.523c-.21.221-.368.443-.473.664l-.307.648a39.53 39.53 0 01-.565 1.278c-.122.255-.338.504-.647.747zm11.736.498c-1.54 0-2.95-.194-4.225-.581s-2.39-.985-3.329-1.793c-.93-.808-1.65-1.82-2.175-3.046-.52-1.22-.78-2.66-.78-4.325 0-1.78.282-3.3.847-4.549.564-1.25 1.33-2.28 2.291-3.088.93-.775 2.02-1.35 3.279-1.718 1.26-.371 2.56-.556 3.926-.556 1.03 0 2.06.119 3.088.357 1.03.238 2.06.617 3.105 1.137v4.981h-.747c-.232-.221-.517-.465-.855-.731s-.706-.509-1.104-.73a7.315 7.315 0 00-1.428-.589 6.128 6.128 0 00-1.776-.241c-1.48 0-2.63.517-3.445 1.552-.814 1.03-1.22 2.43-1.22 4.175 0 1.87.434 3.26 1.303 4.184.869.919 2.02 1.38 3.461 1.378.73 0 1.37-.083 1.926-.249s1.03-.365 1.428-.598c.387-.232.719-.473.996-.722s.515-.473.714-.672h.747v4.981l-1.154.498a9.881 9.881 0 01-1.336.465c-.564.155-1.09.274-1.585.357-.493.083-1.14.125-1.951.125m19.129-5.362v-3.885c-.985.1-1.78.185-2.391.257a8.09 8.09 0 00-1.793.423c-.509.177-.905.445-1.187.805s-.423.838-.423 1.436c0 .874.235 1.47.706 1.801s1.16.49 2.084.49c.509 0 1.03-.116 1.561-.349a4.869 4.869 0 001.444-.979m0 2.889-1.071.896c-.316.266-.739.531-1.27.797-.52.255-1.03.448-1.519.581s-1.18.199-2.067.199c-1.65 0-3.02-.553-4.109-1.66-1.09-1.11-1.64-2.5-1.635-4.184 0-1.38.277-2.5.83-3.354.553-.852 1.35-1.53 2.391-2.025 1.05-.509 2.31-.863 3.769-1.063 1.46-.199 3.03-.354 4.715-.465v-.1c0-1.03-.379-1.74-1.137-2.133s-1.9-.589-3.412-.589c-.686 0-1.49.124-2.407.374s-1.82.567-2.689.955h-.498v-4.499c.576-.166 1.51-.362 2.789-.589 1.28-.227 2.58-.34 3.885-.34 3.21 0 5.55.534 7.014 1.602 1.47 1.07 2.2 2.7 2.199 4.889v12.684h-5.777z"/>
  <path d="m4949.5 1522.8-8.5 24.72h-6.475l-8.5-24.72h6.441l5.379 16.751 5.379-16.751zm19.414 6.076-9.413 25.483h-6.242l2.822-7.288-6.84-18.195h6.109l3.918 11.688 3.669-11.688zm20.498 9.33c0 3.07-.838 5.48-2.515 7.247-1.68 1.77-4.05 2.65-7.114 2.648-3.04 0-5.41-.883-7.097-2.648-1.69-1.77-2.53-4.18-2.532-7.247 0-3.1.844-5.53 2.532-7.28 1.69-1.75 4.05-2.63 7.097-2.631 3.05 0 5.42.883 7.106 2.648 1.68 1.77 2.52 4.19 2.523 7.263m-5.96.033c0-1.11-.091-2.03-.274-2.764s-.434-1.33-.755-1.768c-.343-.465-.73-.789-1.162-.971-.432-.183-.924-.274-1.478-.274-.52 0-.991.08-1.411.241-.421.16-.808.468-1.162.921-.332.432-.598 1.02-.797 1.776s-.299 1.7-.299 2.839c0 1.14.094 2.06.282 2.764.188.703.432 1.26.73 1.685.31.432.697.747 1.162.946s.98.299 1.544.299c.465 0 .938-.1 1.419-.299a2.628 2.628 0 001.154-.896c.343-.476.603-1.05.78-1.718s.266-1.6.266-2.781m27.724 9.28h-6.906l-5.047-8.118-.896 1.212v6.906h-5.811v-25.832h5.811v14.476l5.512-7.288h6.856l-6.524 8.035zm7.018.515c-1.37 0-2.67-.149-3.893-.448-1.22-.299-2.23-.647-3.03-1.046v-4.914h.481c.277.21.592.443.946.697.354.255.847.52 1.478.797.542.255 1.15.473 1.834.656a8.52 8.52 0 002.216.274c.819 0 1.54-.127 2.167-.382.625-.255.938-.659.938-1.212 0-.432-.144-.758-.432-.979s-.847-.432-1.677-.631c-.443-.111-1-.23-1.677-.357s-1.27-.274-1.793-.44c-1.46-.454-2.56-1.13-3.295-2.017-.736-.891-1.1-2.06-1.104-3.511 0-.83.191-1.61.573-2.349.382-.736.944-1.39 1.685-1.967.742-.564 1.66-1.01 2.748-1.345 1.09-.332 2.32-.498 3.694-.498 1.31 0 2.51.13 3.603.39s2.02.573 2.773.938v4.715h-.465a10.648 10.648 0 00-.946-.623c-.432-.26-.852-.484-1.262-.672-.487-.221-1.03-.404-1.635-.548s-1.22-.216-1.851-.216c-.841 0-1.55.144-2.133.432-.581.288-.872.67-.872 1.146 0 .421.144.753.432.996s.913.482 1.876.714c.498.122 1.07.241 1.718.357s1.27.274 1.868.473c1.34.432 2.35 1.07 3.046 1.901.691.836 1.04 1.95 1.037 3.329 0 .874-.205 1.71-.614 2.499a5.64 5.64 0 01-1.743 2.001c-.797.587-1.73 1.04-2.814 1.361-1.08.321-2.37.481-3.877.481m22.599-5.379v-3.885c-.985.1-1.78.185-2.391.257a8.104 8.104 0 00-1.793.423c-.509.177-.904.445-1.187.805-.282.36-.423.838-.423 1.436 0 .874.235 1.47.706 1.801.47.326 1.16.49 2.083.49.509 0 1.03-.116 1.561-.349a4.869 4.869 0 001.444-.979m0 2.889-1.071.896c-.315.266-.739.531-1.27.797a8.58 8.58 0 01-1.519.581c-.492.133-1.18.199-2.067.199-1.65 0-3.02-.553-4.109-1.66-1.09-1.11-1.64-2.5-1.635-4.184 0-1.38.277-2.5.83-3.354.554-.852 1.35-1.53 2.391-2.025 1.05-.509 2.31-.863 3.768-1.063s3.03-.354 4.715-.465v-.1c0-1.03-.379-1.74-1.137-2.133s-1.9-.589-3.412-.589c-.686 0-1.49.124-2.407.374-.918.249-1.82.567-2.689.955h-.498v-4.499c.575-.166 1.5-.362 2.789-.589s2.58-.34 3.884-.34c3.21 0 5.55.534 7.015 1.602 1.47 1.07 2.2 2.7 2.199 4.889v12.684h-5.777z"/>
 </g>
</svg>

@TrySound
Copy link
Member

Looks like this was fixed

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

No branches or pull requests

3 participants