drdk / grunt-dr-svg-sprites

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

Fatal error: Cannot read property 'x' of null #45

Closed phloe closed 9 years ago

phloe commented 9 years ago

This error is sometimes encountered when using layout: packed - any other value seems to work fine.

I haven't been able to reproduce it yet - so I'm leaving this issue open for people to find.

wellhairy commented 9 years ago

Is there any news on this? Layout packed seems to always fail over a given number of sprites

phloe commented 9 years ago

Oh - you're able to reproduce the error reliably? - I hadn't been able to do that - which is why the issue has been floating around like this.

wellhairy commented 9 years ago

Yeah I think it's to do with the number of sprites but it could also be to do with the total size or area I guess. I'll have a few compiles at work tomoz and see what is and isn't working.

wellhairy commented 9 years ago

This is the strangest thing, i've tried several things and it turns out the reason the packed layout wasn't compiling for me was to do with a single svg. There's nothing seemingly different about the svg's code. tried re-saving it and then copying the vector to a new file and saving i, it still fails to compile.

It turns out it was due to the specific svg and it's name; "arrow-grey-large.svg", after re-naming a few of the other sprites a couple of them excepted the "arrow-grey-large.svg" and one other didn't.

Would it be helpful to upload the working files somewhere?

phloe commented 9 years ago

Yes - that would be very helpful! :)

I've been totally in the dark regarding this issue.

wellhairy commented 9 years ago

I've created a repo: https://github.com/wellhairy/dr-grunt-test-examlpe

The sprites are output to the images folder, in the images folder are folders that contain all of the working sprites called icons, this is whats being built. And problems, problems contains groups of both working and failing svgs.

phloe commented 9 years ago

Thanks - that example is excellent!

I already had a hunch the bug was related to an external module (layout) - but without a failing case like the example you provided I wasn't able to test out whether there was anything to it. Updating said module from version 2.0.0 to 2.2.0 seems to fix the bug! (They switched the packing algorithm for the better...)

I'll push an update of grunt-dr-svg-sprites and dr-svg-sprites later today.

Thanks again for the working/failing testcase :)

wellhairy commented 9 years ago

Glad I could help, Thanks for all the hard work it's much appreciated ;)

phloe commented 9 years ago

v0.9.30 is now published with the fix :+1: