drdk / grunt-dr-svg-sprites

Grunt plugin to create SVG sprites with PNG fallbacks at needed sizes
113 stars 19 forks source link

Erroneous sprite generation with version 0.9.30 #49

Closed jbengtssondn closed 9 years ago

jbengtssondn commented 9 years ago

We've been having troubles with sprite generation since the update to version 0.9.30. For some (but not all) sprite generation scenarios our icons are "cut off" in the resulting svg and png, and I also believe the result CSS give strange results sometimes. I can't explain the problem more detailed than that at the moment, but I have attached a part of our generated sprite to this Issue as an example.

cutoff correct

After investigating the issue, I came to the conclusion that the bug must have been introduced as a part of the dependency update in version 0.9.30, since I was able to solve the problem by fixing grun-dr-svg-sprites to version 0.9.15 and two of its dependencies to an older version in my own main package.json. To be specific I changed from:

"grunt-dr-svg-sprites": "^0.9.15",

TO:

"async": "0.9.0", "dr-svg-sprites": "0.9.21", "grunt-dr-svg-sprites": "0.9.15",

This problem is hard to reproduce since the problem doesn't occur consistently. I have only found a problem for two different icons in two projects, whereas the problem hasn't been found for other projects. And if I remove some of our icons from the sprite generation input the output sometimes looks good, and sometimes not. But either way, this sporadic and inconsistent behaviour is a problem. Do you have any idea what this problem can be caused by and how it can be fixed? I can provide you with more information if needed.

phloe commented 9 years ago

Is the error at least consistent on the same machine with the same options/files?

The major thing that changed from dr-svg-sprites 0.9.21 to 0.9.30 was a fix in the layout module (from 2.0.0 to 2.2.0) regarding options.layout when it was set to packed. Are any of the sprites using that option?

jbengtssondn commented 9 years ago

Yes, the error is consistent with the same options and files. Even on different machines.

Yes, we are using packed as our options.layout

persyl commented 9 years ago

Same problem for me (as we are using more or less same functionality as @jbengtssondn ) So for now I had to set to older version: "grunt-dr-svg-sprites": "0.9.15"

and also: "dr-svg-sprites": "0.9.20"

wellhairy commented 9 years ago

I'm not sure if this is related but there's a bug in illustrator where by if you re-save an svg the svg appears off center after you compile the sprite sheet. The way around this specific bug is by re-saving the rogue svg as a as a new svg (not just re-saving it). This is just a bug specific to illustrator, it doesn't happen in sketch and may not be anything to do with this but it's a problem i've had in the past.

On Wed, Aug 5, 2015 at 8:02 AM, Per Lundkvist notifications@github.com wrote:

Same problem for me (as we are using more or less same functionality as @jbengtssondn https://github.com/jbengtssondn ) So for now I had to set to older version: "grunt-dr-svg-sprites": "0.9.15"

and also: "dr-svg-sprites": "0.9.20"

— Reply to this email directly or view it on GitHub https://github.com/drdk/grunt-dr-svg-sprites/issues/49#issuecomment-127895856 .

Kind Regards

Allan King Digital Media Design & Illustration behance.net/wellhairy

phloe commented 9 years ago

Would it be possible to create a reduced testcase with the options used and some of the svg elements that get clipped? Or if you're comfortable with sending all of the svg elements and options that would be fine too :)

The previous error caused by the layout module had nothing to do with how the svg elements were saved - but this new error (seeing as it's a different algorithm altogether) might actually have as @wellhairy suggests. Can't rule anything out just yet :)

jbengtssondn commented 9 years ago

@rasmusfl0e I have sent you a email to the address specified on your github profile with our options and svg elements used.

I think the output less file also has some erroneous valus, but I can't really specify what goes wrong

phloe commented 9 years ago

OK - I think I've managed to fix the bug for the time being ;)

dr-svg-sprites depends on svgo to read the svg elements (and optimise them ofc) and the updated version was thrown off by something in your toolbar-icon-prio.svg (I'm guessing the positioning back and forth of the icon when the white backplate was added?).

So I downgraded the svgo dependency back down to 0.4.5 and the files you sent me now build nicely :)

I published version 0.9.31 ready for use.

jbengtssondn commented 9 years ago

version 0.9.31 works great, thanks a lot!

kirylrb commented 8 years ago

Still have same issue with 0.9.31 - icons cutted on top with both horizontal and packed layouts.

phloe commented 8 years ago

@craft37 can you provide a failing test case?