LaserWeb / LaserWeb4

Collaborative effort on the next version of LaserWeb / CNCWeb
GNU Affero General Public License v3.0
714 stars 193 forks source link

"RangeError: Invalid string length" #507

Open professorofmit opened 6 years ago

professorofmit commented 6 years ago

Follow this steps to open an issue

I got the following error when uploading the included SVG files into Laserweb, and I wanted to learn how to solve this issue.

The file has serious issues. If you think is not your fault, report to LW dev team attaching the file. "RangeError: Invalid string length"

laserweb issue.zip

professorofmit commented 6 years ago

I tried opening my SVG files at https://laserweb.github.io/LaserWeb4/, and I couldn't get them to work there either. Chrome displayed the following error: "Aw Snap! Something went wrong while displaying this webpage."

colmoneill commented 6 years ago

Curious to hear if you found a solution for this, I have the same error : when I try to load a large .svg (4.1MB) into lw, I get multiple different errors returned depending on the environment.

Locally the error is:

The file has serious issues. If you think is not your fault, report to LW dev team attaching the file.
"**InternalError: Invalid string length**" 

When attempting a file load via https://laserweb.github.io/LaserWeb4/ on Firefox I get this:

The file has serious issues. If you think is not your fault, report to LW dev team attaching the file.
"**InternalError: allocation size overflow**" 

Finally, trying the same on Chrome returns the horrible stuck page with the following message

"Aw Snap! Something went wrong while displaying this webpage."  

The file I'm working on is so large because it is a portion of a map. When I remove 80% of the paths manually in Inkscape, I'm able to load the file with no problems, which leads me to believe this is a file size problem, does Electron limit file size uploads ?

Best of luck

lischenko commented 4 years ago

In case it helps with debugging, I am seeing "RangeError: Invalid string length" with this 60KB svg file in LaserWeb 4.0.996 on a Mac.

Untitled-F_Cu.svg.zip

lischenko commented 4 years ago

I tried minimizing the svg contents that still trigger the issue for me. It does not seem to be directly caused by the file size. For example, here is a small 507 byte long svg file that still triggers the "RangeError: Invalid string length" message for me. It has one big circle (and a few empty groups) so I theorize that the issue may be caused by the length of its interpretation (many tiny arcs or something).

Someone else who knows anything about LW might see more into it.

small.svg.zip

cprezzi commented 4 years ago

That small.svg also doesn't work when opened in Inkscape! How did you create it?

cprezzi commented 4 years ago

@lischenko I have analyzed the Untitled-F_Cu.svg and the problem is, that the objects are not closed pathes but single lines. For example, all the middle pads are just lines with 2mm width. That could not work for vector engraving as the laser has a fixed with of 0.1-0.3mm. For vector engraving, your file must only have thin closed contours (like 0.1mm) with no fill color. An infill must be made with a "Laser Fill Path" operation.

For PCBs, the easyer solution is to save the file as a JPG or PNG and use the "Laser Raster" operation.

lischenko commented 4 years ago

Thank you for looking into it, @cprezzi !

The small.svg does open in Inkscape v1.0b2 on Mac OS for me (needs a lot of zoom out else the entire view is black - there is a giant circle after all).

I created small.svg by progressively removing and modifying XML nodes of the Untitled-F_Cu.svg. Just in case, here are some intermediate, larger files in case they are useful - they all fail to open in LW for me: svgs.zip

Also, the small.svg does open in LW if I remove any of the empty groups or reduce the radius of the circle.

The explanation for Untitled-F_Cu.svg explains a lot to me! Still, I would expect the same message as for empty files today ("Error: No supported tags found."). For context, Untitled-F_Cu.svg is an example of what KiCAD (Pcbnew) outputs from its Plot operation, too bad it is not useful out of the box. I'll find a way to turn thick lines into countours, but that's an extra prep step.

The raster workaround works, but it has disadvantages: slower to engrave and the lines are not as sharp.

To summarize, I can see some short term potential improvements for LW: