objective c - What causes this EXC_CRASH in my iPad app? -
i got symbolicated stack trace crash report ipad app (excerpt):
exception type: exc_crash (sigabrt) exception codes: 0x00000000, 0x00000000 crashed thread: 0 0 imageio 0x34528eb4 _cgimagepluginidentifypng + 0 1 imageio 0x34528d90 _cgimagesourcebindtoplugin + 368 2 imageio 0x34528bda cgimagesourcegetcount + 26 3 uikit 0x341b8f66 _uiimagerefatpath + 366 4 uikit 0x342650ce -[uiimage initwithcontentsoffile:] + 50 5 uikit 0x342b0314 +[uiimage imagewithcontentsoffile:] + 28 6 designscene 0x00013a2a -[ltimagecache fetchimageforurl:] (ltimagecache.m:37) …
here contents of -[ltimagecache fetchimageforurl:]
:
- (uiimage *)fetchimageforurl:(nsstring *)theurl { nsstring *key = theurl.md5hash; return [uiimage imagewithcontentsoffile:[self filenameforkey:key]]; }
and contents of -[ltimagecache filenameforkey:]
:
- (nsstring *) filenameforkey:(nsstring *) key { return [_cachedir stringbyappendingpathcomponent:key]; }
the _cachedir
ivar created , retained in -init
. question is, caused crash? problem that:
- the return value of
-[ltimagecache filenameforkey:]
needs retained (it's autoreleased) - an unhandled exception somewhere (
+[uiimage imagewithcontentsoffile:]
claims returnnil
if image unrecognizable) - something else…i'm out of guesses
i think autoreleased value fine. in truth, code has been working fine months, , method called 100s of times in session. rare crash under specific circumstances (the app left loaded overnight, crash upon unlocking ipad in morning).
what's causing crash?
i'm guessing looks bogus image file. in app bundle or download it?
i don't think has memory mgt.
to test try using imageio open file yourself.
cgimagesourceref imagesource = cgimagesourcecreatewithurl((cfurlref)self.url, null); if(null != imagesource) { size_t imagecount = cgimagesourcegetcount(imagesource); if(imagecount > 0) { nsdictionary *options = [nsdictionary dictionarywithobjectsandkeys: [nsnumber numberwithbool:yes], kcgimagesourcecreatethumbnailfromimageifabsent, [nsnumber numberwithinteger:maxsize], kcgimagesourcethumbnailmaxpixelsize, nil]; cgimageref thumbimage = cgimagesourcecreatethumbnailatindex(imagesource, 0, (cfdictionaryref)options); self.image = [uiimage imagewithcgimage:thumbimage scale:scale orientation:imageorientation]; cgimagerelease(thumbimage); cfrelease(imagesource); [pool drain]; } } else { nslog(@"unable open image %@", self.url); }
and try find image count.
using maxsize
, getting thumbnail ensure don't load 5 mega-pixel image put 100x100 tile on ui.
scale
window's scale (will 2 iphone 4 , 1 else).
to find orientation need use cgimagesourcecopypropertiesatindex
function , kcgimagepropertyorientation
key orientation of particular image.
Comments
Post a Comment