Closed nuno-vieira closed 2 years ago
Possibly this is related to this reported crash: https://github.com/kirualex/SwiftyGif/issues/143 since our crash is also on that line.
Sorry for the ping @kirualex. Could you give an estimation on when this can be merged and released?
Thank you!
Description
Hello 👋 First of all, thank you for open sourcing this library 🙂
We have some customers reporting this crash, and we were able to reproduce it and fix it 🙂 Here is the crash log: Crash.txt
How to reproduce
It is a bit hard to reproduce this one. In our case, this happens because sometimes we make a call to
setGifFromURL
right before the view is deallocated. So one way to try and reproduce this is to callsetGifFromURL
on adeinit
lifecycle of an object.Cause
The
URLSession
completion block retains self which prolongs the image view lifetime even if itssuperview
and delegate have been deallocated already. When accessing the unsafe delegate, the app crashes.Solution
By not retaining self on the
URLSession
completion block, and weakly referencing it, it won't crash. I noticed that the same is happening on NSImageView so I applied the same fix.