Appreciate any help fixing a crash (EXC_BAD_ACCESS) in my iOS app. I am seeing this since updating my app to iOS 8, using latest available iOS 8.1.2. The same code worked fine i
First of all sorry for the late answer but maybe it will help someone with a same problem. Main reason is that imageIO cant load image as fast as you need for my example i was reordering UITableViewCell
. Maybe It will help someone with his logics. And try to load Image into NSData and then convert to UIImage.
For example in cellForRowAtIndexPath
let image = UIImagePNGRepresentation(self.imageArray[indexPath.row])
let returnImage = UIImage(data: image)
So if you load returnImage
into imageIO func or func which uses CGContext, try to give the value returnImage
It happened to me too. In my case while clipping a picture. My guess it was because the iCloud was suffering from a temporary networking glitch. Probably best to file a bug report.
I was getting this error because the api I called was throwing a 500 and returning html error page in the tmp >> NSData file I was trying to convert to PNG.
I was presuming a statusCode of 200 and the tmp was png.
You may wish to check the file your trying to open is an image at all before conversion.
You can check bytesize of file is 199641 and put in break point
heres how I tracked down CGImageSource issue when downloading the image
func urlSession(_ session: URLSession, downloadTask: URLSessionDownloadTask, didFinishDownloadingTo location: URL){
print("didFinishDownloadingToURL[\(location) countOfBytesReceived:\(downloadTask.countOfBytesReceived)]")
if let httpResponse = downloadTask.response as? HTTPURLResponse{
if httpResponse.statusCode == 200{
//----------------------------------------------------------------------------------------
//200 - start
//----------------------------------------------------------------------------------------
if (downloadTask.countOfBytesReceived == 199641){
//bytesize metioned in
: ImageIO: CGImageReadGetBytesAtOffset : * ERROR * CGImageSource was created with data size: 203207 - current size is only: 199641
}else{
//----------------------------------------------------------------------------------------
//Image OK
//----------------------------------------------------------------------------------------
}
//----------------------------------------------------------------------------------------
//200 - 3nd
//----------------------------------------------------------------------------------------
}
else if httpResponse.statusCode == 500
{
//check the tmp file in location path
}else{
}
}else{
appDelegate.log.error("ERROR downloadTask.response NOT HTTPURLResponse for taskDescription:'\(cacheKeyString)' - 500")
}
}