Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

"Export All Assets" can swap files due to pngcrush shared tempfile #16

Open
iccir opened this issue Jul 8, 2017 · 3 comments
Open

"Export All Assets" can swap files due to pngcrush shared tempfile #16

iccir opened this issue Jul 8, 2017 · 3 comments

Comments

@iccir
Copy link

iccir commented Jul 8, 2017

pngcrush uses a temp file (I believe pngout.png) when running. When "Export All Assets" is used, multiple NSTask's are created, all of which use pngcrush. One pngcrush can write to the temp file and then another pngcrush reads from it.

Steps to reproduce:

  1. Remove advpng and optipng from compress-full-png.sh. This ensures that pngcrush will always override the file rather than bailing.
  2. Export All Assets

The following document:

screen shot 2017-07-07 at 9 15 22 pm

Produces these results:

screen shot 2017-07-07 at 9 15 28 pm

@iccir
Copy link
Author

iccir commented Jul 8, 2017

Note: this won't show up usually since advpng or optipng will probably produce a smaller file than pngcrush would produce. The failure case occurs when pngcrush produces the smaller file.

@iccir
Copy link
Author

iccir commented Jul 9, 2017

From the pngcrush changelog:

Added "-ow" (overwrite) option. The input file is overwritten and the
output file is just used temporarily and removed after it is copied
over the input file.. If you do not specify an output file, "pngout.png"
is used as the temporary file. Caution: the temporary file must be on
the same filesystem as the input file. Contributed by a group of students
of the University of Paris who were taking the "Understanding of Programs"
course and wished to gain familiarity with an open-source program.

It looks like the fix is adding a tempfile name after the input file name:

"$basedir"/pngcrush -ow -reduce -blacken -bail -rem alla -new "$1" "$1".tmp

@pcolton
Copy link

pcolton commented Apr 2, 2019

I saw a similar issue just today, after an Export All, one of my exported png images was the wrong size (seemed to be a file from another size).

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

No branches or pull requests

2 participants