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

Crash while loading images in iOS 10 #1367

Closed
hamzabinamin opened this issue Dec 10, 2019 · 9 comments · Fixed by #1371
Closed

Crash while loading images in iOS 10 #1367

hamzabinamin opened this issue Dec 10, 2019 · 9 comments · Fixed by #1371
Assignees

Comments

@hamzabinamin
Copy link

hamzabinamin commented Dec 10, 2019

I am getting the following exception whenever I try to load an image through a given url. This only happens in iOS 10. In iOS 13 there's no exception and the image loads perfectly fine.

Thread 8: EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)

    var timeInterval: TimeInterval {
        switch self {
        case .never: return .infinity
        case .seconds(let seconds): return seconds
        case .days(let days): return TimeInterval(TimeConstants.secondsInOneDay * days)
        case .date(let ref): return ref.timeIntervalSinceNow
        case .expired: return -(.infinity)
        }
    }

The exception occurs at the case.days line

SDK version is v.5.7.0.

@onevcat
Copy link
Owner

onevcat commented Dec 11, 2019

Thanks for the report. I will check it soon later!

@onevcat onevcat self-assigned this Dec 11, 2019
@onevcat
Copy link
Owner

onevcat commented Dec 13, 2019

Cannot reproduce it in the sample app, at least with the latest 5.11.0.

Not sure why it can crash on iOS 10. Are you trying to set a very large days value?

Or, could you please try to upgrade to the latest version and check whether this crash is still there?

Thanks.

@hamzabinamin
Copy link
Author

I'm using a customer support SDK that it using kingfisher to load attachment images. I have also opened a ticket on their github profile but they were also not able to reproduce the error. So unfortunately I can't update to a newer version directly.

First I thought the crash was happening as I was also importing kingfisher as a podfile (as I was also using it to load images). I then removed it, now it only gets imported from their sdk. But the crash still occurs. It doesn't matter if images are being loaded in my code or being loaded under their view controller. The crash occurs as soon as there is an image loading process.

Weirdly enough everything works fine on iOS 13.

I know this doesn't directly correspond as a bug on your end maybe they are doing something wrong but at this point we're stuck with their sdk and they haven't been much helpful about this.

I am attaching a link to their repository maybe you can see if they're using it incorrectly somewhere.
https://github.com/customerly/Customerly-iOS-SDK

Also I found that in their code, they are using the following value for storage expiration

//Image cache expiration after one day
 ImageCache.default.diskStorage.config.expiration = StorageExpiration.days(86400)

Link to the page containing the above code snippet,
https://github.com/customerly/Customerly-iOS-SDK/blob/master/CustomerlySDK/Library/Customerly.swift

Thank you so much for your help so far.

@onevcat
Copy link
Owner

onevcat commented Dec 13, 2019

Thanks for the feedback. It is not related to the iOS system version, but due to the 32-bit int on old devices. :(

I fixed it in the PR above and will schedule a release for it soon. However, it is not quite possible to release a patch for 5.7.x for it. I strongly suggest they also upgrade it, or temporarily set a shorter cache duration.

@onevcat
Copy link
Owner

onevcat commented Dec 13, 2019

Although they wrote:

//Image cache expiration after one day
ImageCache.default.diskStorage.config.expiration = StorageExpiration.days(86400)

But the cache is not one day, it is now 236 years.

@hamzabinamin
Copy link
Author

That makes a lot of sense now, at-least we now know why its happening.

For the time being, is it somehow possible that I can modify the code that is causing the crash on 32-bit devices?

Would it help with the crash if I set a shorter expiration date?

@onevcat
Copy link
Owner

onevcat commented Dec 13, 2019

Sure, you can just check my code in #1371 to have a fix.

Or you can just overwrite the ImageCache.default.diskStorage.config.expiration in your code after Customerly set theirs value. Caching a file for 236 years does not that make sense. If their comment is correct, it should be just .days(1) or .seconds(86400). If you want to cache them forever, use ImageCache.default.diskStorage.config.expiration = .never instead.

@hamzabinamin
Copy link
Author

Ok thank you, I'll try out setting the expiration time and will get back to you. Thank you so much for your help.

@onevcat
Copy link
Owner

onevcat commented Dec 13, 2019

5.12.0 was released in a fix for this was contained.

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

Successfully merging a pull request may close this issue.

2 participants