Flipboard/FLAnimatedImage — pull request #58 by chrismarcellino (2014-12-11 21:35:29+00:00)
Title: FLAnimatedImage low memory notification warning crasher fixes

This change uses an NSHashTable to prevent deallocation races that are causing occasional crashes when memory warnings fire. The FLAnimatedImage objects are being released on background threads (intended) as they are used in background queues. There is a race with the NSNotificationCenter callouts, as even though we check in the first line didRecieveMemoryWarning: if we have been deallocated, this doesn't prevent deallocation further in the method as we aren't referenced strongly by NSNotificationCenter (which isn't complied in ARC btw.) This is essentially because NSNotificationCenter does not retain the objects it is notifying during it's callouts, which is arguably correct behavior since NSNotificationCenter doesn't retain it's objects when registering to prevent retain cycles. Rolling our own notifier with NSHashTable allows us to fix this.

Note that FLAnimatedImages can be created on any thread, so the hash table must be locked.