Skip to content
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

Bug with AlamoFireImage #75

Closed
patchthecode opened this issue Jan 22, 2016 · 13 comments
Closed

Bug with AlamoFireImage #75

patchthecode opened this issue Jan 22, 2016 · 13 comments

Comments

@patchthecode
Copy link

myProg(63494,0xb029b000) malloc: *** error for object 0x79b5ce80: double free
*** set a breakpoint in malloc_error_break to debug

screen shot 2016-01-22 at 4 25 25 am

@jshier
Copy link
Contributor

jshier commented Jan 27, 2016

Is it possible for your to provide some of your calling code? We're unlikely to be able to fix this without knowing how it's triggered.

@jshier jshier added the bug label Jan 27, 2016
@jshier jshier self-assigned this Jan 27, 2016
@patchthecode
Copy link
Author

Here is my calling code:

class ImageLoaderWorker {
    private let imageCache = AutoPurgingImageCache()
    private let imageDownloader = ImageDownloader(
        configuration: ImageDownloader.defaultURLSessionConfiguration(),
        downloadPrioritization: .FIFO,
        maximumActiveDownloads: 5,
        imageCache: AutoPurgingImageCache())

    var imageLinks:   [String] = []
    var imageCacheID: [String] = []



    func downloadBatchOfImages(completionHandler:(imageArray: [UIImage?])->Void) {

        var count: Int = imageLinks.count
        var images = [UIImage?](count: count, repeatedValue:nil)

        // Convert URL strings into URL objects
        var urls: [URLRequestConvertible] = []
        for imageLink in imageLinks {
            let urlRequest = NSURLRequest(URL: NSURL(string: imageLink)!)
            urls.append(urlRequest)
        }

        // Begin downloading images
        imageDownloader.downloadImages(URLRequests: urls, filter: nil) { (response) -> Void in
            let urlStringJustDownloaded = response.request?.URL?.absoluteString
            let indexToInsert = self.imageLinks.indexOf(urlStringJustDownloaded!)!

            if let image = response.result.value {

                // jt101 Should i cache images here?
                images[indexToInsert] = image

            } else {
                print ("something went wrong. Image was not loaded in ImageLoaderWorker")
                // something went wrong is downloading the file. Use default image.
                images[indexToInsert] = UIImage(named: "1.jpg")
            }

            count--

            // TODO: What if the image does not download?
            if count < 1 {
                completionHandler(imageArray: images)
            }
        }
    }
}

On this call i only download 4 images.
As a side note, sometimes when the images load every thing is fine. The Crash bug above does not happen. Other times it does. It is not a consistent crash. Also to note some times i receive this message: error: [/BuildRoot/Library/Caches/com.apple.xbs/Sources/CoreUI/CoreUI-371.4/Bom/Storage/BOMStorage.c:522] is not a BOMStorage file. And just like the crash, sometimes that error message shows up, and other times it doesnt.

Need any other info? let me know

@cnoon
Copy link
Member

cnoon commented Feb 4, 2016

Is there any chance you could submit a sample project that reproduces this behavior @patchthecode? That would make it much easier to diagnose if there's actual an AFI issue here or something with your logic. Nothing you posted in your example looks problematic.

@patchthecode
Copy link
Author

ok, its part of a larger project. I will scale out the problem part and submit it in a while

@cnoon
Copy link
Member

cnoon commented Feb 6, 2016

After thinking through this some more, I'm almost positive this is due to the non-thread safe UIImage initializer. I'm going to switch the response serializer over to using the thread-safe initializer. I should have done this right from the start.

@cnoon cnoon assigned cnoon and unassigned jshier Feb 6, 2016
@cnoon cnoon added this to the 2.4.0 milestone Feb 6, 2016
@cnoon
Copy link
Member

cnoon commented Feb 6, 2016

Should be resolved with 85048ff. @patchthecode, if you could retest with the latest commits on master, that would be great!

@cnoon cnoon closed this as completed Feb 6, 2016
@cnoon
Copy link
Member

cnoon commented Feb 6, 2016

I'll gladly re-open this issue if the problem persists.

@patchthecode
Copy link
Author

Ok. I am using this framework from cocoa pods. I just did a 'Pod Install' to update the framework.
If the problem happens again, will let you know. Thanks for your awesome work

@cnoon cnoon modified the milestones: 2.3.1, 2.4.0 Feb 8, 2016
@patchthecode
Copy link
Author

Happened again today. I did a Pod init (in cocoa pod.. i assume the update you did is already there?)

screen shot 2016-02-08 at 12 28 52 am

screen shot 2016-02-08 at 12 30 34 am

@cnoon
Copy link
Member

cnoon commented Feb 8, 2016

Are you loading any other images using UIImage(data:) or UIImage(data:scale:) in your code outside of AlamofireImage? If yes, that's certainly the issue. Additionally, you do not have the 2.3.1 release. That has been updated to use the thread-safe UIImage initializer.

@patchthecode
Copy link
Author

No i am not loading any other images outside of alamoFireImage. However, i just looked at what you said about the release number. Seems i was still using version 2.2 in my Cocoapod file. I have now changed version to *** pod 'AlamofireImage', '~> 2.3' *** and did an update. It the error happens again after this update, then i will just give you a copy of the problem code so that you can run it. Thanks for the help. Will update you if it happens again after the update.

@patchthecode
Copy link
Author

Update: Since after updating. No more crashes. And i'm not get the BOMStorage file warning messages anymore. All seems well. Thanks for your work. Have a good one.

@cnoon
Copy link
Member

cnoon commented Feb 11, 2016

That's great to hear @patchthecode! Thanks for reporting that back to us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants