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

Corrupt PNG on sprite - System Crash #860

Closed
thomaswelton opened this issue Apr 26, 2012 · 12 comments
Closed

Corrupt PNG on sprite - System Crash #860

thomaswelton opened this issue Apr 26, 2012 · 12 comments
Assignees
Labels

Comments

@thomaswelton
Copy link

Compass Version 0.11.7
SASS Version 3.1.7
Mac OS X 10.7.3

It's possible for compass to cause a system wide crash if it attempts to create a sprite from corrupt png.

I was updating an existing sprite image by working in photoshop, I saved this file and put it in my sprite directory, edited some SCSS when compass watch kicked in and started eating up all of my computers resources.

It took me a while, and several computer restarts, to find out why my computer was being so slow until I managed to open my finder and delete the corrupt png at which point compass compile threw a file not found error when trying to create the sprite.

I reopened photoshop, re-saved the file and everything was fine. I'm not sure what was wrong with the image as it opened and displayed in Preview, but opening it in photoshop I got this error "Could not complete your request because the file-format module cannot parse the file."

The problem was reasonably difficult for a dev to spot before trying to create a sprite, and if the sprite generator kicks in a computer restart is required for it to become responsive again.

I still have the problematic png here http://thomas.clicklabs.co.uk/corrupt-png-compass-test.png

@ohrstrom
Copy link

ohrstrom commented May 2, 2012

Hi there

I just had the same experience - nearly systemwide crash when trying to compile a sass project with sprites.
If you take a look at your file - it is not a corrupted png, but a JPEG image with a .png extension... This causes the crash.
Actually it is rather a memory-leak than a system crash [Don't know much about this things, maybe i0m wrong].

With jpegs named as png cmpass/ruby eats up all memory. On my system [OS X 10.7.3] cpu usage was still low but it wanted to use several GBs of ram.

So finally this is not really a bug - as the problems are caused by the user :) But maybe it would be possible to avoid a freeze...

@thomaswelton
Copy link
Author

This is a bug as Compass crashed my system, the user error did not cause the system crash, compass did.
If Compass can not build a sprite it should report an error in the same way it does if it can not compile a stylesheet (feature request maybe)

@ohrstrom
Copy link

ohrstrom commented May 2, 2012

Yes it should maybe not rely on the file extension to determine the image type.
About the 'caused by the user' - try to rename a dvd-image to readme.txt and open it with nano... this will also use all your memory.

@scottdavis
Copy link
Member

this sounds like an issue with the png library and not compass... lets ping @wvanbergen

@wvanbergen
Copy link

This is not a problem in ChunkyPNG. The attached image is a JPEG, not a PNG image. Trying to read it with ChunkyPNG is raising an error, as expected:

> ChunkyPNG::Image.from_file 'jpeg_with_png_extension.png'
ChunkyPNG::SignatureMismatch: PNG signature not found!

My guess is the error handling in Compass may not handle this exception properly.

@scottdavis
Copy link
Member

so ChunkyPNG::SignatureMismatch is an exception i can catch then?

@ghost ghost assigned scottdavis May 9, 2012
@wvanbergen
Copy link

Yeah, or just ChunkyPNG::Exception to catch any problem that the PNG may have.

@scottdavis
Copy link
Member

rather be specific in my catch so i can display a proper error message consider this on my list of things to get done.

@thomaswelton
Copy link
Author

Thank you guys, much appreciated.

@gigafied
Copy link

This is still kind of an issue. Somehow (don't ask me how), a PSD file got saved as a PNG file and checked into the project. The PSD was smallish (33 KB), so it wasn't super obvious.

Anyway, basically when I tried to compile a sprite sheet, ruby ended up leaking a huge amount of memory, (in Activity Monitor, it showed over 13GB of actual used memory).

This is, of course, insane, there needs to be a better way of handling and catching something like this. The first time I tried it, the process just hung (terminal was in the background and I was doing something else), all of a sudden my comp just crashed. When I rebooted and tried to run it again, I noticed the hung process and opened Activity Monitor.

Took me a lot of trial and error to discover the issue and the PSD saved as a PNG. Ideally, Compass/ChunkyPNG would be able to spit some kind of warning/error out.

I'm not sure if this is a ChunkyPNG or Compass error however.

@pauloalem
Copy link

Today a jpeg saved as png filled up all of my memory in a matter of seconds. If there's any way I can help with this, please tell me.
I'm using compass (1.0.0.alpha.17), sass (3.3.0.rc.2) and the offending file is attached, but I guess any jpeg file with a different extension will do.
swimming

@jasonsemko
Copy link

Had this as well, could someone please add lines in verbose mode to explain what files compass is looking at as it moves through sprite generation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants