AlamofireImage: Crash in af_inflate
Crashed: NSOperationQueue 0x17e84a130 :: NSOperation 0x17e8449c0 (QOS: UTILITY) 0 CoreGraphics 0x182347bc4 CGDataProviderCopyData + 236 1 CoreGraphics 0x182347bc4 CGDataProviderCopyData + 236 2 InfatuationSwift 0x100185be0 @objc UIImage.af_inflate() -> () (UIImage+AlamofireImage.swift:110) 3 InfatuationSwift 0x10021a47c static Request.(imageResponseSerializer(imageScale : CGFloat, inflateResponseImage : Bool) -> ResponseSerializer<UIImage, NSError>).(closure #1) (Request+AlamofireImage.swift:99) 4 InfatuationSwift 0x10021a0f8 partial apply for thunk (Request+AlamofireImage.swift) 5 Alamofire 0x10073a390 TFFC9Alamofire7Request8responseuRxS_22ResponseSerializerTyperFT5queueGSqPSo17OS_dispatch_queue__18responseSerializerx17completionHandlerFGVS_8Responsewx16SerializedObjectwx11ErrorObject_T__DS0_U_FT_T + 436 6 Alamofire 0x100737cfc TPA__TFFC9Alamofire7Request8responseuRxS_22ResponseSerializerTyperFT5queueGSqPSo17OS_dispatch_queue__18responseSerializerx17completionHandlerFGVS_8Responsewx16SerializedObjectwx11ErrorObject_T__DS0_U_FT_T + 144 7 Foundation 0x181958510 NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK + 16 8 Foundation 0x1818aa900 -[NSBlockOperation main] + 96 9 Foundation 0x18189aed8 -[__NSOperationInternal _start:] + 604 10 Foundation 0x18195a904 __NSOQSchedule_f + 224 11 libdispatch.dylib 0x1809e947c _dispatch_client_callout + 16 12 libdispatch.dylib 0x1809f54c0 _dispatch_queue_drain + 864 13 libdispatch.dylib 0x1809ecf80 _dispatch_queue_invoke + 464 14 libdispatch.dylib 0x1809f7390 _dispatch_root_queue_drain + 728 15 libdispatch.dylib 0x1809f70b0 _dispatch_worker_thread3 + 112 16 libsystem_pthread.dylib 0x180c01470 _pthread_wqthread + 1092 17 libsystem_pthread.dylib 0x180c01020 start_wqthread + 4
Not sure exactly when the crash occurred, but I got this from Crashlytics. Appears to be after the line CGDataProviderCopyData(CGImageGetDataProvider(CGImage))
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 22 (5 by maintainers)
@soryncrash13 Since this is a memory related issue, that’s not surprising – your simulator has access to a lot more memory than your phone! See my comment.
Yep, @blixt is spot on. You need to be a bit careful loading massive images onto mobile devices. You’ll simply run out of memory. Right now, AFI assumes you have already done the leg work to make sure you aren’t loading 10k x 10k images on your own. Apple has many other avenues to load images with that high of a resolution.
We’re encountering this issue too, and we spent a lot of time trying to narrow down the problem. We narrowed it down to a specific image causing the crash. In fact, I can get it to crash without even using the library. If I create a test project and run the following code on an iPhone 7+ with the latest OS (it doesn’t crash on simulator) using the attached image, it will crash every time:
We can’t figure out what is wrong with this image. We’ve tried using online metadata validators and comparing this image with both larger and smaller renditions that don’t crash, and everything seems identical.
Now, I realize that this obviously means the underlying bug isn’t with the library (I’m suspecting it’s a CGImage bug). But because we don’t know what else to change, our only option is to not use the library, so I’m putting this info here in case someone can figure out what we can change to use the library, or maybe there’s a less performant way to inflate images that we could use in a fork, or something, because we really like what the library provides.
I hope this info can help someone smarter than me find the problem. 😄