Reading CGImageRef in a background thread crashes the app

眉间皱痕 提交于 2019-12-06 11:37:37

I finally found out my problem...

I have read the Quartz2D doc and it seems that we should not use CGDataProviderCreateWithData and CGImageCreateWithJPEGDataProvider anymore. I guess there usage is not thread safe.

As suggested by the doc, i now use CGImageSource API like this :

self.imageSrcRef = CGImageSourceCreateWithData((__bridge CFDataRef)imgData, NULL);

// get imagePropertiesDictionary
CFDictionaryRef imagePropertiesDictionary = CGImageSourceCopyPropertiesAtIndex(m_imageSrcRef,0, NULL);

self.imageRef = CGImageSourceCreateImageAtIndex(m_imageSrcRef, 0, imagePropertiesDictionary);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!