-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Crashes on SessionDelegate.remove() when canceling Download Task #1511
Comments
We are also getting the same issue and are using version "5.14.1" via carthage when canceling image requests within prepareForReuse()
|
We are using 5.14.0 via CocoaPods |
Tried to fix in 5.15.5. If anyone can confirm it. |
We encountered this same crash when cancelling a bunch of image requests. Our stack trace looks like:
From the email chain we had with DTS:
I'm seeing references to |
This patch adds/adjusts some lock behaviors. This should help to avoid racing for accessing originalRequest properties and fix #1511
@danielbyon-hulu Ummm, that is really hidden pitfall. Nice to hear that it is fixed in iOS 14. We cannot use the request directly as the key. The current implementation is an optimization to prevent multiple downloading from the same URL. Changing an object identifier key (the hash of request, etc) would break this feature. May I know is it possible for you to build a stable reproducible sample? So we can use that to check whether a fix works or not. Anyway, I tried to adjust some locks to make sure the accessing of Any feedback is welcome! |
Unfortunately, we've only ever seen this crash in NewRelic monitoring, we've never been able to repro locally. I looked at your PR and added comments. |
This patch adds/adjusts some lock behaviors. This should help to avoid racing for accessing originalRequest properties and fix onevcat#1511
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
What
We are using Kingfisher to download images for our iOS app and I have encountered many crashes when trying to cancel a download task
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000020
For example we call this method when reusing cells in a tableview, where we cancel requests for cells that are not longer visible. We have created an extension on UIImageView to define convenience methods like cancel()
What could be the reason for this crash? The download task in our code is an optional, so even when the object is not there anymore, calling image?.downloadTask.cancel() should not create crashes, should not even trigger those methods.
Here is a Sample code of what we do:
We call the cancel method when reusing cells in our collection view:
Reproduce
I cannot share the URL that we call, but we've notice that it happens most of the time when the network request have been canceled from the server.
Info from New Relic:
Other Comments
The UI updates (assign of UIImageViews) and the cancelation of request when are happening are being done in the Main Thread.
The text was updated successfully, but these errors were encountered: