andrew-raphael-lukasik / pngcs

PNG encoding and decoding for Unity engine
42 stars 5 forks source link

API Async methods sometimes fail to return texture object #2

Open andrew-raphael-lukasik opened 5 years ago

andrew-raphael-lukasik commented 5 years ago

You may want to stay away from async calls until this is solved. Because these methods sometimes return null. Any info and repro steps on this will be highly appreciated

ddutchie commented 5 years ago

Async Saving does not work for me

texture.isReadable is only available on main thread texture GetDataWidth also.

Keen to see where this goes. Having issues saving massive textures on mobile.

andrew-raphael-lukasik commented 5 years ago

Thanks @ddutchie for reporting this. Fortunately it's really easy to fix and caused by just silly mistake on my part I didn't pickup earlier. Well and it shows why unit testing is a really good idea for these kind of projects.

aidanwolf commented 5 years ago

Also having this issue. Did async calls ever work?

aidanwolf commented 5 years ago

According to my tests, Read/Write with pngcs are 1.6x slower than using Unity's EncodeToPNG() and LoadImage().

andrew-raphael-lukasik commented 5 years ago

Hi @aidanwolf. PNGCS is slower because it's designed for "huge images, which one does not want to load fully in memory" (original readme.txt), ie. memory conservation rather than speed. PNGCS realises this goal reading images line by line, and decoding data line by line. But this behaviour can be modified to regain speed

andrew-raphael-lukasik commented 5 years ago

Also having this issue. Did async calls ever work?

Yes BUT there is a bug somewhere and I can't figure out what it is exactly. I can reproduce it always happening on 1st program execution after editor is (re)started and works fine after that. I tried to figure out what is happening on several occasion but no results so far. I even contacted Unity support with this issue but yet to receive answer from them. If you guys happen to notice any code-smell or have any leads for this issue please let me know!