-
Notifications
You must be signed in to change notification settings - Fork 523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
UIImage.af_inflate(): Failed to grow buffer crash #332
Comments
on our app we got the same crash... it's not that frequent 3 times so far, and with iPhones 6s exclusively (at least for now) |
Thanks for the reports! I think this issue has been around for a while and I'm pretty sure the only fix is to disable manual image inflation, as apps can't always control the size of images they're downloading, and apparently the underlying API can fail to claim memory. We'll investigate our options. |
Hi @jshier, do you have anymore updates on this? Our app has been receiving a lot of these crashes and our users have escalated. Reproducing it has been a problem since there's no clear repro steps. Same call stack and it's been primarily on iOS 12. |
Hey everyone, @jshier is on point here as the core issue is inflating images with extremely large sizes which can run your app out of memory. We do have a temporary workaround, but a proper solution here is going to be much more involved in changing the way we force decompression on compressed images. What you can do right now is one of the following: Option 1 - Disabling Inflation EntirelyUIImageView.af_sharedImageDownloader.imageResponseSerializer = DataRequest.imageResponseSerializer(inflateResponseImage: false) This will essentially disable image inflation for all A better, more focused approach would be to disable image inflation only on image views that can render images of an unknown size. One way you could do this is as follows: Option 2 - Disabling Inflation Per UIImageViewlet downloader = ImageDownloader()
downloader.imageResponseSerializer = DataRequest.imageResponseSerializer(inflateResponseImage: false)
let imageView = UIImageView()
imageView.af_imageDownloader = downloader Long Term SolutionA longer term solution would be for us to figure out how to resolve the memory allocation issue in the low-level Apple APIs we're calling to force the inflation. This will require quite a bit of work on our part and unfortunately we do not have the bandwidth at the moment to take this on. We're currently working to complete the Alamofire 5 release. Once that is complete, this AFI will be first on our list to get resolved. Cheers. 🍻 |
Has there been any progress on this issue? |
@iosdevben No. Given this is an issue within the memory allocation routines of CoreGraphics / CoreFoundation, it's hard to investigate, and we haven't had much time with the pending release of Alamofire 5. I'm attending WWDC, so I'll be speaking to Apple engineers about how we can be safer here or alternate approaches to inflating images asynchronously. For anyone seeing this crash, filing an Apple bug and posting the bug number can help us get Apple to look at it. |
Facing same crash in production, any permanent workaround on this issue. |
Hi @jshier, did you get any advice from the Apple engineers at WWDC on how to resolve this? |
We tried option 2 from cnoon's suggestions, but that lead to a follow-up issue (See crash log below). Any idea what could be causing this?
|
@mickyzinho That doesn't seem related to this issue. @iosdevben I was unable to speak to anyone about this issue, unfortunately. It would interesting to see if anyone is seeing this crash on iOS 13. Perhaps this was fixed during that release? |
@jshier This issue is definitely still happening on iOS 13 unfortunately. |
Hi guys, any news on this? Thanks, |
The proper solution here is to rebuild the inflation logic to rasterize the image which will do two things: 1) decompress the original data and 2) redraw the image in a pixel format optimized to go to screen. Right now we're taking a shortcut to simply decompress the original data. However, I'm not entirely sure if the proper solution would solve your issue. If you load an image that is going to run your application out of memory, then you can't load the image that way. As a temporary workaround, you can disable the inflation a few different ways. I've updated the main AFI usages to support a custom let imageView = UIImageView()
imageView.af_setImage(
withURL: url,
serializer: ImageResponseSerializer(imageScale: 4.0, inflateResponseImage: false)
) You can also do this by setting a custom ImageDownloader.default.imageResponseSerializer = ImageResponseSerializer(inflateResponseImage: false) However, I'm not entirely sure this will solve your issue, but just change the stack trace. If you try to load an image that is large than you app can handle, it's going to crash regardless. It just won't crash anymore in our inflation logic, but will crash when trying to decompress the data as part of the draw pipeline. If you do need to blindly load super large images, then you need to load them in a much safer way than we do with AFI. See this Stack Overflow thread for some good information on how to do this along with a sample app from Apple. Just for full transparency, this is not an issue we will solve any time soon. We are focusing on getting the AFI 4.0.0 release out, and then will focus entirely on some additional large new features going into Alamofire 5.x. Once we address all of those, we may circle back to AFI with a large rework of all the functionality. However, this will not be anytime soon. Cheers all. |
For a couple of weeks, this issue is starting to pop up in our app as well. This is strange because the app does not support iOS 13 anymore. Where some previous comments pointed towards. |
Alamofire Environment
Alamofire version: Alamofire (4.7.3), AlamofireImage (3.4.1)
Xcode version: 10.0
Swift version: 4.0
Platform(s) running AlamofireImage: iOS
macOS version running Xcode: 10.14
I have been receiving numerous crash reports from iOS 12 users only with the latest version of AlamofireImage. I am not sure if this is an issue caused by iOS 12 or a change to AlamofireImage itself.
Unfortunately, I don't know more information than the crash info below so I cannot recreate the cause.
The text was updated successfully, but these errors were encountered: