Asynchronous image downloader with cache support as a UIImageView category


Build Status Pod Version Pod Platform Pod License Carthage compatible SwiftPM compatible Mac Catalyst compatible codecov

This library provides an async image downloader with cache support. For convenience, we added categories for UI elements like UIImageView, UIButton, MKAnnotationView.


Supported Image Formats

  • Image formats supported by Apple system (JPEG, PNG, TIFF, BMP, ...), including GIF/APNG animated image
  • HEIC format from iOS 11/macOS 10.13, including animated HEIC from iOS 13/macOS 10.15 via SDWebImageHEICCoder. For lower firmware, use coder plugin SDWebImageHEIFCoder
  • WebP format from iOS 14/macOS 11.0 via SDWebImageAWebPCoder. For lower firmware, use coder plugin SDWebImageWebPCoder
  • Support extendable coder plugins for new image formats like BPG, AVIF. And vector format like PDF, SVG. See all the list in Image coder plugin List

Additional modules and Ecosystem

In order to keep SDWebImage focused and limited to the core features, but also allow extensibility and custom behaviors, during the 5.0 refactoring we focused on modularizing the library. As such, we have moved/built new modules to SDWebImage org.


SwiftUI is an innovative UI framework written in Swift to build user interfaces across all Apple platforms.

We support SwiftUI by building a brand new framework called SDWebImageSwiftUI, which is built on top of SDWebImage core functions (caching, loading and animation).

The new framework introduce two View structs WebImage and AnimatedImage for SwiftUI world, ImageIndicator modifier for any View, ImageManager observable object for data source. Supports iOS 13+/macOS 10.15+/tvOS 13+/watchOS 6+ and Swift 5.1. Have a nice try and provide feedback!

Coders for additional image formats

Custom Caches

Custom Loaders

  • SDWebImagePhotosPlugin - plugin to support loading images from Photos (using Photos.framework)
  • SDWebImageLinkPlugin - plugin to support loading images from rich link url, as well as LPLinkView (using LinkPresentation.framework)

Integration with 3rd party libraries

Community driven popular libraries

  • FirebaseUI - Firebase Storage binding for query images, based on SDWebImage loader system
  • react-native-fast-image - React Native fast image component, based on SDWebImage Animated Image solution
  • flutter_image_compress - Flutter compresses image plugin, based on SDWebImage WebP coder plugin

Make our lives easier

You can use those directly, or create similar components of your own, by using the customizable architecture of SDWebImage.


  • iOS 9.0 or later
  • tvOS 9.0 or later
  • watchOS 2.0 or later
  • macOS 10.11 or later (10.15 for Catalyst)
  • Xcode 11.0 or later

Backwards compatibility

Getting Started

Who Uses It


  • If you need help, use Stack Overflow. (Tag 'sdwebimage')
  • If you'd like to ask a general question, use Stack Overflow.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you need IRC channel, use Gitter.


How To Use

  • Objective-C
#import <SDWebImage/SDWebImage.h>
[imageView sd_setImageWithURL:[NSURL URLWithString:@""]
             placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
  • Swift
import SDWebImage

imageView.sd_setImage(with: URL(string: ""), placeholderImage: UIImage(named: "placeholder.png"))

Animated Images (GIF) support

In 5.0, we introduced a brand new mechanism for supporting animated images. This includes animated image loading, rendering, decoding, and also supports customizations (for advanced users).

This animated image solution is available for iOS/tvOS/macOS. The SDAnimatedImage is subclass of UIImage/NSImage, and SDAnimatedImageView is subclass of UIImageView/NSImageView, to make them compatible with the common frameworks APIs.

The SDAnimatedImageView supports the familiar image loading category methods, works like drop-in replacement for UIImageView/NSImageView.

Don't have UIView (like WatchKit or CALayer)? you can still use SDAnimatedPlayer the player engine for advanced playback and rendering.

See Animated Image for more detailed information.

  • Objective-C
SDAnimatedImageView *imageView = [SDAnimatedImageView new];
SDAnimatedImage *animatedImage = [SDAnimatedImage imageNamed:@"image.gif"];
imageView.image = animatedImage;
  • Swift
let imageView = SDAnimatedImageView()
let animatedImage = SDAnimatedImage(named: "image.gif")
imageView.image = animatedImage

FLAnimatedImage integration has its own dedicated repo

In order to clean up things and make our core project do less things, we decided that the FLAnimatedImage integration does not belong here. From 5.0, this will still be available, but under a dedicated repo SDWebImageFLPlugin.


There are four ways to use SDWebImage in your project:

  • using CocoaPods
  • using Carthage
  • using Swift Package Manager
  • manual install (build frameworks or embed Xcode Project)

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.


platform :ios, '8.0'
pod 'SDWebImage', '~> 5.0'
Swift and static framework

Swift project previously had to use use_frameworks! to make all Pods into dynamic framework to let CocoaPods work.

However, starting with CocoaPods 1.5.0+ (with Xcode 9+), which supports to build both Objective-C && Swift code into static framework. You can use modular headers to use SDWebImage as static framework, without the need of use_frameworks!:

platform :ios, '8.0'
# Uncomment the next line when you want all Pods as static framework
# use_modular_headers!
pod 'SDWebImage', :modular_headers => true

See more on CocoaPods 1.5.0 — Swift Static Libraries

If not, you still need to add use_frameworks! to use SDWebImage as dynamic framework:

platform :ios, '8.0'
pod 'SDWebImage'


There are 2 subspecs available now: Core and MapKit (this means you can install only some of the SDWebImage modules. By default, you get just Core, so if you need MapKit, you need to specify it).

Podfile example:

pod 'SDWebImage/MapKit'

Installation with Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods.

To install with carthage, follow the instruction on Carthage

Carthage users can point to this repository and use whichever generated framework they'd like: SDWebImage, SDWebImageMapKit or both.

Make the following entry in your Cartfile: github "SDWebImage/SDWebImage" Then run carthage update If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

NOTE: At this time, Carthage does not provide a way to build only specific repository subcomponents (or equivalent of CocoaPods's subspecs). All components and their dependencies will be built with the above command. However, you don't need to copy frameworks you aren't using into your project. For instance, if you aren't using SDWebImageMapKit, feel free to delete that framework from the Carthage Build directory after carthage update completes.

Installation with Swift Package Manager (Xcode 11+)

Swift Package Manager (SwiftPM) is a tool for managing the distribution of Swift code as well as C-family dependency. From Xcode 11, SwiftPM got natively integrated with Xcode.

SDWebImage support SwiftPM from version 5.1.0. To use SwiftPM, you should use Xcode 11 to open your project. Click File -> Swift Packages -> Add Package Dependency, enter SDWebImage repo's URL. Or you can login Xcode with your GitHub account and just type SDWebImage to search.

After select the package, you can choose the dependency type (tagged version, branch or commit). Then Xcode will setup all the stuff for you.

If you're a framework author and use SDWebImage as a dependency, update your Package.swift file:

let package = Package(
    // 5.1.0 ..< 6.0.0
    dependencies: [
        .package(url: "", from: "5.1.0")
    // ...

Manual Installation Guide

See more on Manual install Guide

Import headers in your source files

In the source files where you need to use the library, import the umbrella header file:

#import <SDWebImage/SDWebImage.h>

It's also recommend to use the module import syntax, available for CocoaPods(enable modular_headers)/Carthage/SwiftPM.

@import SDWebImage;

Build Project

At this point your workspace should build without error. If you are having problem, post to the Issue and the community can help you solve it.

Data Collection Practices

As required by the App privacy details on the App Store, here's SDWebImage's list of Data Collection Practices.




Thank you to all the people who have already contributed to SDWebImage.



All source code is licensed under the MIT License.


To learn about SDWebImage's architecture design for contribution, read The Core of SDWebImage v5.6 Architecture. Thanks @looseyi for the post and translation.

High Level Diagram

Overall Class Diagram

Top Level API Diagram

Main Sequence Diagram

More detailed diagrams

  • SDWebImage from LPLinkMetadata in UICollectionViewCell

    SDWebImage from LPLinkMetadata in UICollectionViewCell

    New Issue Checklist

    Issue Info

    Info | Value | -------------------------|-------------------------------------| Platform Name| ios Platform Version| 13.2.1 SDWebImage Version| 5.0.0 Integration Method| carthage Xcode Version| Xcode 11 Repro rate| n/a Repro with our demo prj| n/a Demo project link| n/a

    Issue Description and Steps

    This is more of a question than an issue. Can LPLinkMetaData be used with SDWebImage when loading data into a UICollectionViewCell, if one does not choose to use LPLinkView?

    feature request apple bug 
    opened by inPhilly 134
  • Memory problem or leak on iOS 7 ?

    Memory problem or leak on iOS 7 ?

    Hello everybody, I'm sorry in advance as maybe this is a dumb and noob question...

    I'm using SDWebImage to display pictures in a UITableView in my cellForRowAtIndexPath method, using the classic

    [cell.pointPicture setImageWithURL:[NSURL URLWithString:thePoint.imageURL] placeholderImage:[UIImage imageNamed:POINT_DEFAULT_IMAGE]];

    (the displayed pictures are light and well compressed jpgs, just some ko) When I inspect my app with "Instrument - Allocations", and just scroll down my UITableView (with 40 cells containing picture, a bit like Instagram), I got a huge amount of memory used ! (see screenshot)


    But it seems to be "VM", and especially "VM: CG raster data" from the coreGraphics library.

    So the questions are :

    • Is it normal?
    • Is that a serious problem?
    • Is there a way to avoid this?

    I'm sorry but after few search on the web I can't find any relevant information concerning the "VM: CG raster data"... Any idea? Thanks in advance !

    bug performance GIF 
    opened by kefon 128
  • SDImageIOAnimatedCoder crash only happened on iOS 15

    SDImageIOAnimatedCoder crash only happened on iOS 15

    New Issue Checklist

    Issue Info

    Info | Value | -------------------------|-------------------------------------| Platform Name |ios Platform Version |15.0 SDWebImage Version |5.10.4 Integration Method |cocoapods Xcode Version |Xcode 12.3 Repro rate |sometimes 0.5%

    Issue Description and Steps

    0 CoreFoundation CFDataGetBytes + 156 4 UIKitCore 0x0000000184200000 + 16248057818473156320 5 GoShare2 0x0000000104a34000 + 1599128611935478020 6 GoShare2 -[SDImageIOAnimatedCoder animatedImageFrameAtIndex:] (SDImageIOAnimatedCoder.m:0) 7 GoShare2 -[SDAnimatedImage animatedImageFrameAtIndex:] (SDAnimatedImage.m:0) 8 GoShare2 __43-[SDAnimatedImagePlayer displayDidRefresh:]_block_invoke (SDAnimatedImagePlayer.m:0) 9 Foundation 0x0000000183580000 + 333168 21 libsystem_pthread.dylib _pthread_wqthread + 4047424897389953252

    apple bug ImageIO 
    opened by WJustin 89
  • Memory problem that caused the crash

    Memory problem that caused the crash

    Info | Value -|- Platform Name | ios Platform Version | 11.2 SDWebImage Version | 4.3.0 Integration Method | cocoapods Xcode Version | Xcode 9.2 Repro rate | all the time

    HI,friend UICollectionView Load more than twenty webp animations Memory problem that caused the crash

    crash stale 
    opened by lzylzy1991 62
  • Crash at -[SDWebImageDownloaderOperation start]

    Crash at -[SDWebImageDownloaderOperation start]

    After updating to e8c5ed17c01de9bcfe330b974561f0ec94b49286 from a very old version, I started to see a crash with following stack trace. This is iOS 6, so far happened with iPhone 4S & iPhone5.

    Fatal Exception NSInvalidArgumentException
    -[**NSSetI postUpdatesIfNecessary]: unrecognized selector sent to instance 0x1fdd7d00
    0    CoreFoundation  __exceptionPreprocess + 162
    1    libobjc.A.dylib     objc_exception_throw + 30
    2    CoreFoundation  -[NSObject(NSObject) doesNotRecognizeSelector:] + 170
    3    CoreFoundation  ___forwarding_** + 392
    4    CoreFoundation  _CF_forwarding_prep_0 + 24
    5    CoreTelephony   ___SendInternalNotification_sync_block_invoke_0 + 32
    7    CoreFoundation  __CFRunLoopDoTimer + 272
    8    CoreFoundation  __CFRunLoopRun + 1232
    9    CoreFoundation  CFRunLoopRunSpecific + 356
    10   CoreFoundation  CFRunLoopRun + 98
    11   wanelo      -[SDWebImageDownloaderOperation start]
    12   Foundation  __block_global_6 + 102
    13 ...   libdispatch.dylib   _dispatch_call_block_and_release + 10
    14   libdispatch.dylib   _dispatch_root_queue_drain + 252
    15   libdispatch.dylib   _dispatch_worker_thread2 + 84
    16   libsystem_c.dylib   _pthread_wqthread + 360
    17   libsystem_c.dylib   start_wqthread + 8
    opened by servercimen 45
  • Crash at -[SDWebImageDownloaderOperation start]

    Crash at -[SDWebImageDownloaderOperation start]

    OS: iOS 7.1 Device: iPhone5 Stacktrace:

    Thread : Fatal Exception: NSGenericException 0 CoreFoundation 0x2d93ef03 exceptionPreprocess + 130 1 libobjc.A.dylib 0x380d3ce7 objc_exception_throw + 38 2 CoreFoundation 0x2d93e9f1 -[NSException name] 3 Foundation 0x2e2a8b27 -[NSISEngine substituteOutAllOccurencesOfBodyVar:withExpression:] + 442 4 Foundation 0x2e2ab797 -[NSISEngine pivotToMakeBodyVar:newHeadOfRowWithHead:andDropRow:] + 338 5 Foundation 0x2e2a9541 -[NSISEngine minimizeConstantInObjectiveRowWithHead:] + 236 6 Foundation 0x2e2abf97 -[NSISEngine tryUsingArtificialVariableToAddConstraintWithMarker:rowBody:usingInfeasibilityHandlingBehavior:mutuallyExclusiveConstraints:] + 226 7 Foundation 0x2e2a7811 -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 692 8 Foundation 0x2e2a744f -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 282 9 Foundation 0x2e2a516d -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 228 10 UIKit 0x3025e27d -[UIView(UIConstraintBasedLayout) layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 368 11 UIKit 0x302655c9 -[UIView(UIConstraintBasedLayout) constraints_didChangeAutoresizingConstraintsArrayForContainedView:] + 196 12 UIKit 0x3025e90d -[UIView(UIConstraintBasedLayout) _updateAutoresizingConstraints] + 112 13 UIKit 0x3025e84d -[UIView(AdditionalLayoutSupport) updateConstraints] + 120 14 UIKit 0x306fa2f3 -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 246 15 UIKit 0x3026224b -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 126 16 CoreFoundation 0x2d8721d9 CFArrayApplyFunction + 36 17 UIKit 0x306fa28d -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 144 18 UIKit 0x3026224b -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 126 19 CoreFoundation 0x2d8721d9 CFArrayApplyFunction + 36 20 UIKit 0x306fa28d -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 144 21 UIKit 0x3026224b -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 126 22 CoreFoundation 0x2d8721d9 CFArrayApplyFunction + 36 23 UIKit 0x306fa28d -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 144 24 UIKit 0x3026224b -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 126 25 CoreFoundation 0x2d8721d9 CFArrayApplyFunction + 36 26 UIKit 0x306fa28d -[UIView(AdditionalLayoutSupport) _internalUpdateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 144 27 UIKit 0x3026224b -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededAccumulatingViewsNeedingSecondPass:] + 126 28 Foundation 0x2e2a4d33 -[NSISEngine withBehaviors:performModifications:] + 210 29 UIKit 0x3027c0e7 -[UIWindow(UIConstraintBasedLayout) updateConstraintsIfNeeded] + 218 30 UIKit 0x301ead1f -[UIWindow(UIConstraintBasedLayout) layoutSublayersOfLayer:] + 86 31 QuartzCore 0x2fdea31b -[CALayer layoutSublayers] + 142 32 QuartzCore 0x2fde5b3f CA::Layer::layout_if_needed(CA::Transaction) + 350 33 QuartzCore 0x2fde59d1 CA::Layer::layout_and_display_if_needed(CA::Transaction) + 16 34 QuartzCore 0x2fde53e5 CA::Context::commit_transaction(CA::Transaction_) + 228 35 QuartzCore 0x2fde51f7 CA::Transaction::commit() + 314 36 QuartzCore 0x2fddef1d CA::Transaction::observer_callback(_CFRunLoopObserver, unsigned long, void) + 56 37 CoreFoundation 0x2d90a031 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION* + 20 38 CoreFoundation 0x2d9079bf __CFRunLoopDoObservers + 286 39 CoreFoundation 0x2d907d0b __CFRunLoopRun + 738 40 CoreFoundation 0x2d8727a9 CFRunLoopRunSpecific + 524 41 CoreFoundation 0x2d8b63cb CFRunLoopRun + 98 42 musiXmatch 0x001d9853 -SDWebImageDownloaderOperation start 43 Foundation 0x2e316745 __NSOQSchedule_f + 60 44 libdispatch.dylib 0x385c125f _dispatch_async_redirect_invoke + 110 45 libdispatch.dylib 0x385c2689 _dispatch_root_queue_drain + 228 46 libdispatch.dylib 0x385c28dd _dispatch_worker_thread2 + 56 47 libsystem_pthread.dylib 0x386edc17 _pthread_wqthread + 298 48 libsystem_pthread.dylib 0x386edadc start_wqthread + 8

    opened by loretoparisi 44
  • SDWebImage 5.0.0 release checklist

    SDWebImage 5.0.0 release checklist

    This is supposed to help us track the remaining things for 5.0.0 release.

    5.0.0-beta release checklist

    • [x] simulate a merge from 5.x to master to see what the overall changes are
    • [x] review and improve naming across the project - #2291
    • [x] check public entities that could be moved to dedicated files (i.e. SDWebImageCombinedOperation)
    • [x] review all the entities we now have in the 5.x branch and see if any should be moved to a dedicated project (like a coder or something else). We should keep this project minimal.
    • [x] #define LOCK(lock) ... and #define UNLOCK(lock) ... should not be duplicated in each file where they are used - done in f8fe886
    • [x] update docs
      • [x] update readme on the support for animated images and examples
    • [x] update and add #2275
    • [x] review open issues/prs with no milestone
    • [x] remove FLAnimatedImage support entirely #2385
    • [x] publish 5.0.0-beta1

    5.0.0-beta2 release checklist

    • [x] Add SDImageCoderWebImageContext coder option, which allow custom coder plugin, to receive the context option from top-level API #2405
    • [x] Updated all existing diagrams for 5.0 release + added new ones (small detailed diagrams for the most important components) #2407
    • [x] Change SDImageFormat to use NS_TYPED_EXTENSIBLE_ENUM instead of fixed enum, to allow custom coder plugins to extend it #2400
    • [x] publish 5.0.0-beta2

    5.0.0-beta3 release checklist

    • [x] Feature disk cache migration from 4.x #2417 #2433
    • [x] Add default HTTP User-Agent for specific system #2409
    • [x] Improved unit tests #2438 #2434
    • [x] Adopt all the protocol APIs which contains getter value to use property instead, to make the API easy to use or Swift user #2452
    • [x] Remove sd_setAnimationImagesWithURLs API, because its cause ambiguity, behave not consistently and have rare use case #2459
    • [x] Extra args for SDSetImageBlock (added cacheType and imageURL) #2449
    • [x] publish 5.0.0-beta3

    5.0.0-beta4 release checklist

    • [x] move webp component to dedicated project SDWebImage/SDWebImageWebPCoder #2469
    • [x] Carthage improvements: no libwebp and FLAnimatedImage dependencies + offer 2 targets (SDWebImage and SDWebImageMapKit) to people can choose which one to install #2476
    • [x] fix Progressive decoding (for large images) runs too frequently #2477 - solutions #2478 #2479 or #2480
    • [x] another review of the README, CHANGELOG, MIGRATION GUIDE to 5.x docs per latest 5.x changes #2388

    5.0.0-beta5 relase checklist

    • [x] Fix encoding options does not works #2602
    • [x] Remove unnecessary CGImage check when encode first frame #2609

    5.0.0-beta6 release checklist

    • [x] Fix the issue that SDWebImagePrefetch in 5.x, will submit all prefetch URLs to manager without any concurrent limit #2631
    • [x] Fix the current transformer cache key generating rules, try to keep the image file extension #2635
    • [x] Move some internal classes into private header files, make it easy to maintain the code #2634

    5.0.0 official release checklist

    • [x] give the beta(s) some time for feedback gathering. Ask some users to try it out.
    • [x] update the API diff based on the latest 4.x release (4.4.6) and the last 5.0 commit
    • [x] update the API documentation and add link on the Wiki page:
    • [x] update the migration guide for 5.0, with the latest information, update url link from 5.x to master
    • [x] update the full changelog for 5.0
    • [x] check out current master branch into a seperated 4.x branch, for keeping a short term maintain for serious bug
    • [x] merge the 5.x branch into the master (due to PR issue, we now using 5.0 branch), See #2664
    • [x] release the 5.0.0 for CoaoaPods and Carthage

    5.0.0 related coders/plugins repo upgrade

    5.0.0 downstream partner adapting

    • [x] FirebaseUI Support Custom Loader feature. Will release v7.0.0
    • [x] React Native FastImage Support Animated Image instead of FL. Released v6.0.0
    opened by bpoplauschi 43
  • Make create FLAnimatedImage async to improve performance

    Make create FLAnimatedImage async to improve performance

    New Pull Request Checklist

    • [x] I have read and understood the CONTRIBUTING guide

    • [x] I have read the Documentation

    • [x] I have searched for a similar pull request in the project and found none

    • [x] I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)

    • [ ] I have added the required tests to prove the fix/feature I am adding

    • [ ] I have updated the documentation (if necessary)

    • [ ] I have run the tests and they pass

    • [ ] I have run the lint and it passes (pod lib lint)

    This merge request fixes / reffers to the following issues: ...

    Pull Request Description

    The issue comes from #2393 . It makes the FLAnimatedImage created on main thread, it's the big performance penalty, I use the demo of #2377 , the scroll fps downs to 5fps. I reimport the new group class which imitate the behavior of dispatch_group_t but support call notify block synchronously.

    important fix 
    opened by zhongwuzw 42
  • Loads of

    Loads of "invalid context 0x0"

    Hi, when I implemented SDWebImage I got many and many of this error:

    <Error>: CGContextScaleCTM: invalid context 0x0. This is a serious error. This application, or a library it uses, is using an invalid context and is thereby contributing to an overall degradation of system stability and reliability. This notice is a courtesy: please fix this problem. It will become a fatal error in an upcoming update.

    I am loading images to set as the background of my UITableViewCells on my cellForRowAtIndexPath:

    [cell.cityImageView sd_setImageWithURL:imageURL placeholderImage:nil completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        NSLog(@"error: %@", error);

    Reading some stackoverflow topics I have found that some people said that this is an iOS 7 problem that would eventually disappear. But I am using iOS 8 simulator and the error is still there.

    opened by cytryn 41
  • SDWebImage not working with iOS 8

    SDWebImage not working with iOS 8

    'm was developing an app using iOS7 SDK, when I moved to iOS8 SDWebImage stop working properly. If I try this:

    [imgViewTemp setImageWithURL:urlPhoto completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType) { NSlog(@"done"); }]; the completion block simply doesn't get called. Do you have any imminent plan of supporting iOS8?

    opened by ghost 40
  • High memory use

    High memory use

    SDWebImageManager *manager = [SDWebImageManager sharedManager];
    [manager downloadImageWithURL:post.imageURL options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) 
        // float progress = (float)receivedSize/expectedSize;
        // [cell.imageViewFoto updateProgress:progress];
    completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) {
        if (image) {
            [cell.imageViewFoto setupImageView:post indexPath:indexPath isGrid:NO  image:image];
    captura de tela 2016-04-30 as 15 34 24 performance 
    opened by CavalcanteLeo 38
  • wip:Added context option `callbackQueue` for advanced user to control which queue to callback

    wip:Added context option `callbackQueue` for advanced user to control which queue to callback

    New Pull Request Checklist

    • [ ] I have read and understood the CONTRIBUTING guide

    • [ ] I have read the Documentation

    • [ ] I have searched for a similar pull request in the project and found none

    • [ ] I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)

    • [ ] I have added the required tests to prove the fix/feature I am adding

    • [ ] I have updated the documentation (if necessary)

    • [ ] I have run the tests and they pass

    • [ ] I have run the lint and it passes (pod lib lint)

    This merge request fixes / refers to the following issues: ...

    Pull Request Description

    This close #3457



    feature cache 
    opened by dreampiggy 0
  • AVMetadataItemValueRequest & SDWebImageManager.load hang

    AVMetadataItemValueRequest & SDWebImageManager.load hang

    New Issue Checklist

    Issue Info

    Info | Value | -------------------------|-------------------------------------| Platform Name | ios Platform Version | 14.0 - 16.2 SDWebImage Version | 5.12.1 Integration Method | cocoapods Xcode Version | 14.2 Repro rate | all the time (100%) Repro with our demo prj | don't know yet Demo project link | none

    Issue Description and Steps

    • iOS application with AVKit, SDWebImage (cocoapods)
    • Lazy load artwork like that:
    extension AVMetadataItem {
        static func artwork(url: URL, placeholder: UIImage?) -> AVMetadataItem {
            let art = AVMutableMetadataItem()
            art.identifier = .commonIdentifierArtwork
            art.dataType = kCMMetadataBaseDataType_PNG as String
            art.extendedLanguageTag = "und"
            return AVMetadataItem(propertiesOf: art) { request in 
                    .loadImage(with: url, context: [:], progress: nil) { image, _, error, _, _, _ in
                         // no call here at all, hang application before this callback
                        let cover: UIImage?
                        if let image = image {
                            cover = image
                        } else {
                            cover = placeholder
                        guard let data = cover?.pngData() else {
                            request.respond(error: CustomError.loadImageFailed)
                        request.respond(value: data as NSData)

    I found some place in code there is hang started in file SDImageCache.m:

    if (doneBlock) {
                    if (shouldQueryDiskSync) {
                        doneBlock(diskImage, diskData, SDImageCacheTypeDisk);
                    } else {
                        dispatch_async(dispatch_get_main_queue(), ^{ // <<< HERE
                            doneBlock(diskImage, diskData, SDImageCacheTypeDisk);

    This hang happen only when call load image in AVMetadataItem function for lazy load, nothing hangs when load by URLSession.shared Can't yet understand any reason for that :(

    feature request cache 
    opened by iDevPro 18
  • UIImageView sd_setImage SVG error

    UIImageView sd_setImage SVG error

    New Issue Checklist

    Issue Info

    Platform Name iOS Platform Version 16 SDWebImage Version 5.13.4 Integration Method cocoapods Xcode Version Xcode 14.1 Repro rate all the time (100%) for this file Repro with our demo prj NS Demo project link NS

    Issue Description and Steps

    I'm getting the error

    Error Domain=SDWebImageErrorDomain Code=1001 "Downloaded image decode failed" UserInfo={NSLocalizedDescription=Downloaded image decode failed}

    with this url:

    Some others SVG urls works fine.


    cell.imageView?.sd_setImage(with: url, placeholderImage: placeholderImage, options: [.retryFailed], completed: { image, error, cacheType, imageURL in
                    if error == nil, var image = image {

    Any help?

    opened by iDevelopper 2
  • 内存泄漏(memory leak)

    内存泄漏(memory leak)

    New Issue Checklist

    Issue Info

    Info | Value | -------------------------|-------------------------------------| Platform Name ios Platform Version 16.0.1 SDWebImage Version 5.14.2 Integration Method cocoapods Xcode Version Xcode 14.1 Repro rate | e.g. all the time (100%) / sometimes x% / only once Repro with our demo prj | e.g. does it happen with our demo project? Demo project link | e.g. link to a demo project that highlights the issue

    Issue Description and Steps

    截屏2022-12-05 16 52 16

    not enough info 
    opened by tanzhiwei2356 4
  • Should the second parameter of the `CGImageSourceCreateWithData` method be `NULL` in line 404?

    Should the second parameter of the `CGImageSourceCreateWithData` method be `NULL` in line 404?

    New Issue Checklist

    I have read and understood the CONTRIBUTING guide I have read the Documentation I have searched for a similar issue in the project and found none

    Issue Description

    should the second parameter of the CGImageSourceCreateWithData method be NULL in line 404?

    opened by JustLoveBen 3
  • Image not showing

    Image not showing


    Has anyone noticed that images are no longer showing? For the first time when fetching an image from a URL, nothing happens, it just shows the placeholder until maybe when you close the app and open it again. It doesn't show immediately. I thought it was a connectivity issue on my end but multiple people have complained of my app not being able to display images anymore after they cleared the cache, they have to close the app and open it again to see the images.

    This is the code I have been using to load images from URLs and display in the imageview. It's in a UIImageView extension

    sd_setImage(with: URL(string: "\(url)"), placeholderImage: placeholder)

    What could be the problem?

    opened by kelvinoff 0
  • 5.14.3(Dec 27, 2022)

    See all tickets marked for the 5.14.3 release


    • Added ioQueueAttributes to use concurrent or control QoS for image cache internal IO Queue #3460
    • When frame timestamp not reached, we should prefetch frame in advance for image render #3452


    • Fix the iOS 15+ force-decode hack break Apple's HEIF and JPEG YUV420 optimization #3461
    • The poster image should not trigger a frameChange callback #3459
    Source code(tar.gz)
    Source code(zip)
  • 5.14.2(Nov 14, 2022)

  • 5.14.1(Nov 11, 2022)

  • 5.14.0(Nov 8, 2022)

    See all tickets marked for the 5.14.0 release

    Behavior Changes

    • Introduce SDWebImageContextImageDecodeOptions, deprecate SDImageCoderWebImageContext #3421
      • Note the deprecated SDImageCoderWebImageContext is no longer used. Update your codebase to use SDWebImageContextImageDecodeOptions to pass extra information from manager to coder. Loaded image will also store the same information in image.sd_decodeOptions
    • Refactor the hack when multiple different thumbnail image requests for same url called at the same time #3423
      • Now the SDWebImageDownloader can callback each thumbnail request for same url with the correct image size as well (previously can't)
      • Now if manager's callback image is thumbnail (image.sd_isThumbnail == YES), or transformed (image.sd_isTransformed == YES), the callback data will be nil. This because the image does not match downloaded data actually. If you really need original full size data, query the disk cache again using the original key. You may need SDWebImageWaitStoreCache options as well. (previously behavior is undefined, may callback with full size data, or encoded small size data, or even nil)



    • Support use url.path or custom UTI hint passed to ImageIO, solve the TIFF/NEF/SRW raw image decoding with wrong size #3419
      • Note from 5.14.0, we may pass the file extension to coder as a UTI hint
    • Added SDImageCoderDecodeUseLazyDecoding to control whether to use lazy-decoding for ImageIO #3425
      • Note from 5.14.0, by default we enable lazy decoding for static image coder, disable lazy decoding for animated image coder, suitable for most cases. If you want, pass .decodeUseLazyDecoding = YES to context option .imageDecodeOptions


    • Introduce new workaround to strip CGImage retained CGImageSource on iOS 15 #3425 #3387
      • Note this also fix the limitation that you can not use lazy-decoding for animated image on iOS 15+. Pass .decodeUseLazyDecoding = YES to context option .imageDecodeOptions
    • Replace conformsToProtocol call with appropriate respondsToSelector check to improve performance #3429 Thanks @timonus
    • Fix del redundant autoreleasepool #3388 Thanks @dongranGG


    • Avoid store again when origin disk cache hit during Thumbnail or Transformer with smaller pixel size #3428 #3395
    • Add the possible nullable logic check when the force-decode/copy failed #3427
    Source code(tar.gz)
    Source code(zip)
  • 5.13.5(Oct 29, 2022)

  • 5.13.4(Sep 26, 2022)

  • 5.13.3(Sep 19, 2022)

    See all tickets marked for the 5.13.3 release


    • Try to workaround iOS 15+ crash that CGImage retain the CGImageSource during animation image playing #3387
    • Fix the crash because of SDWebImageCombinedOperation recursive lock #3403
    • Synchronise getter and setter of the cancelled property of the SDWebImageCombinedOperation #3393
    • Fix the switching from animated image rendering to static image does not works on macOS 11+ #3402
    Source code(tar.gz)
    Source code(zip)
  • 5.13.2(Jul 23, 2022)

  • 5.13.1(Jul 16, 2022)

    See all tickets marked for the 5.13.1 release


    • Added SDImageCoderHelper.defaultDecodeSolution to control the force decode solution. Automatic by default #3368 #3365
    • Now imageByPreparingForDisplay is only applied for JPEG/HEIF images. If you want the 5.12.0 behavior, set the solution to .coreGraphics instead


    • Fix the PDF image without thumbnailPixelSize will result huge bitmap size, now fixed into 72 DPI matching PDFKit #3370
    • Fix sd_colorAtPoint and sd_colorsWithRect support for grayscale image (white and alpha) #3372


    • Fix the clang analyze issue #3373
    Source code(tar.gz)
    Source code(zip)
  • 5.13.0(Jun 26, 2022)

    See all tickets marked for the 5.13.0 release



    • Change thumbnail cache behavior as expected, share cache through different loading pipeline without extra download #3362
    • Now the thumbnail behavior more like transformer. When request different thumbnail size and cache miss, it prefers to query full size disk cache again, then decode for request thumbnail size without actual network download


    • Added new API for custom coder better handling the thumbnail size #3359


    • Allows store image data only and introduce async API #3336
    • Now the queryCacheOperationForKey API return SDImageCacheToken instead of useless placeholder NSOperation. When you cancel the cache query from main queue, it will callback in sync instead of async


    • Support using iOS 15 UIImage new API imageByPreparingForDisplay for faster force decoding #3355 #3340


    • Fix the encodeMaxPixelSize logic #3357
    • Fix the case when user cancel the image loading for same URL in sequence cause placeholder mass #3363

    Extra - Collaborator and maintainer wanted

    After 4 years of maintainess of SDWebImage open source project, I have met many interesting areas in pass 2 years, like LLVM/Swift, like Rust. And I have the full-time job. So the maintainess will become slower down. If anyone who was interested in the future of SDWebImage open source project, please feel free to contact me via email or discussions 🙏

    Source code(tar.gz)
    Source code(zip)
  • 5.12.6(Jun 12, 2022)


    • Fix the thumbnail pixel size calculation when preserveAspectRatio is true #3354
    • Fix macOS compile on Xcode 14 which missing necessary CoreImage import #3353
    • Fix a crash of accessing +[NSScreen mainScreen] from background thread on OSX 10.11. #3337


    • Small performance improvement to generating file URLs in SDDiskCache -setData:forKey: #3346
    Source code(tar.gz)
    Source code(zip)
  • 5.12.5(Mar 16, 2022)


    • Workaround iOS 15+ force decode again using Image Renderer(preferred) and RGB888 #3334

    This version fix the CoreGraphics warning when using PNG and force-decode(by default without .avoidDecodedImage)

    Source code(tar.gz)
    Source code(zip)
  • 5.12.4(Mar 8, 2022)


    • Fix imageView blinks with option SDImageCacheQueryDiskDataSync #3327
    • Workaround the iOS 15+ Force Decode may return black image because of CoreGraphics #3332
    Source code(tar.gz)
    Source code(zip)
  • 5.12.3(Jan 27, 2022)

  • 5.12.2(Dec 31, 2021)

  • 5.12.1(Oct 15, 2021)


    • Fix ProMotion display issues #3280
    • Add tvos check when use targetTimestamp in displaylink #3286
    • Revert "Fix image source release in iOS 15" in 5.12.0 #3281


    • Since UTI is an standard, we can use it directly to avoid warning on iOS 15 #3282


    • Fix test error #3283
    • Port travis configuration to github actions #3285
    Source code(tar.gz)
    Source code(zip)
  • 5.12.0(Sep 30, 2021)



    • Do a extra memory cache sync when weak cache feature enabled && Change the default value for shouldUseWeakMemoryCache to NO #3239
    • Fix imageFromCacheForKey with options and context behavior, matching the async version one. #3238


    • Feature: allow user to custom acceptable status code and content type #3227
    • Change the default delegate method to allows optional cert in SSL verify, matches URLSession's behavior #3241

    Animated Image

    • Added sd_imageFrameCount convenient API for UIAinmatedImage/NSBitmapImageRep #3243
    • Make SDAnimatedImageRep confirms to correct copy semantic #3258


    • Fix image source release in iOS 15 #3276
    • Fix wrong memory cost in _UIAnimatedImage #3237
    • Fix pixel ratio thumbnail calculation #3277
    • Fix the warning, enable APPLICATION_EXTENSION_API_ONLY for all framework target #3236
    Source code(tar.gz)
    Source code(zip)
  • 5.11.1(Apr 23, 2021)


    • Change the .originalStoreCaheType and .originalQueryCacheType into .disk, Now we will store the full image data into disk and re-query the full image data by default #3219
    • Change the willTerminate auto clean cache logic into sync version #3210


    • Fix the bug that when querying original cache miss, the download process will be skipped. This is not designed behavior #3221
    • Ensure the invalid URLSession will receive the cancel callback and does not trigger the any exception from framework #3205
    Source code(tar.gz)
    Source code(zip)
  • 5.11.0(Apr 1, 2021)



    • Added the new context option SDWebImageContextOriginalImageCache, which control the cache instance used for original full size image query/write when using transformer #3184


    • Increase progressive decoding performance by using the progressive decoder's result instead of re-decoding the full image data #3182
    • Avoid the strong retain during download decoding, this can make the download operation fast to destroy and reduce memory peak, especially in progressive decoding #3183


    • Don't encode/decode image when app will terminated (hotfixed) #3149
    Source code(tar.gz)
    Source code(zip)
  • 5.10.4(Feb 2, 2021)

  • 5.10.3(Jan 24, 2021)

  • 5.10.2(Dec 29, 2020)


    • Fix the case that we setFinished=YES before NSOperation started. This may cause exception from Foundation #3146
    • All 5.10.1 users are recommended to update.
    Source code(tar.gz)
    Source code(zip)
  • 5.10.1(Dec 25, 2020)


    • Fix the race condition when user cancel the network loading will not trigger the completion block #3142
    • Fix deprecation warnings for OSSpinLock #3137
    Source code(tar.gz)
    Source code(zip)
  • 5.10.0(Nov 22, 2020)


    • Bumped the min deployment target version to iOS 9, macOS 10.11. Bumped the min Xcode version to Xcode 11 #3130
    • This effect the downstream dependencies like SDWebImageWebPCoder, you may update them to the latest version at the same time.


    Animated Image

    • Add animation playback mode for SDAnimatedImageView/Player, including reverse, bounce and reversed bounce #3115

    Custom Loader

    • Added the options and context arg for Image Loader custom protocol, this can be used for advanced user to grab and check for context for current loading URL to process the logic #3129


    • Replace all current dispatch_semaphore usage into the os_unfair_lock, use OSSpinLock for lower firmware #3128
    Source code(tar.gz)
    Source code(zip)
  • 5.9.5(Nov 13, 2020)

  • 5.9.4(Oct 23, 2020)


    • Fix race condition when using transitions that are canceled and then switched to a new transition or load operation #3108 #3107
    • Fixed the store cache type was specified to SDImageCacheTypeDisk that no pictures were obtained when the disk had pictures #3110
    Source code(tar.gz)
    Source code(zip)
  • 5.9.3(Oct 13, 2020)


    • Fix coder priority inverse in SDAnimatedImage #3101
    • Fix that SDImageCache will automatically store the disk image into memory cache even if store cache type is disk #3104
    Source code(tar.gz)
    Source code(zip)
  • 5.9.2(Sep 29, 2020)


    • Fix the issue that SDAnimatedImageView will trigger an empty callback when animation stopped. This will cause some bad effect such as rendering a empty image or placeholder image (especially on iOS 14) #3092
    • Fix: duration is not used in SDWebImageTransition convenience initializers. #3094
    Source code(tar.gz)
    Source code(zip)
  • 5.9.1(Sep 11, 2020)

  • 5.9.0(Aug 27, 2020)



    • Supports built-in WebP/AWebP codec from ImageIO for iOS 14/tvOS 14/macOS 11/watchOS 7 #3048
    • To use, add SDImageAWebPCoder to your coders manager. Note built-in WebP currently supports decoding only, for encoding, you still need SDImageWebPCoder
    • Add the support to pass small bytes to decodedAndScaledDownLargeImage, which always scale down (at least 1x1 pixel) but not return the original size #3067


    • Supports the user to customize the default disk cache directory, which can be used to share cache for App && App Extension #3066

    View Category

    • Adjust the current behavior to use transition. Now it automatically do transition when manager callback asynchronously (if user see waiting, then do transition) #3074


    • Fix the bug when the thumbnail pixel size is larger than the pixel size, and the image has EXIF orientation, the final UIImage will use wrong image orientation #3070
    • Fix the image format detection for smaller SVG which less than 100 Bytes #3072
    Source code(tar.gz)
    Source code(zip)
Async image downloader with Mem&Disk cached as a UIImageView extension

HBWebImage Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation HBWebIm

haoboxuxu 1 Oct 22, 2022
🚀SwiftUI Image downloader with performant LRU mem/disk cache.

Progressive concurrent image downloader for SwiftUI, with neat API and performant LRU mem/disk cache.

Cheng Zhang 42 Sep 24, 2022
Multi image downloader with priority in Swift

Vulcan Multi image downloader with priority in Swift Features Very light Multi image download with priority Caching images Pure Swift Composable image

Jin Sasaki 294 Aug 29, 2022
AsyncImage before iOS 15. Lightweight, pure SwiftUI Image view, that displays an image downloaded from URL, with auxiliary views and local cache.

URLImage URLImage is a SwiftUI view that displays an image downloaded from provided URL. URLImage manages downloading remote image and caching it loca

Dmytro Anokhin 1k Jan 4, 2023
An extension that gives UIImageView the ability to focus on faces within an image.

FaceAware Sometimes the aspect ratios of images we need to work with don't quite fit within the confines of our UIImageViews. In most cases we can use

Beau Nouvelle 3k Jan 3, 2023
A simple UIImageView extension for using initials as a profile image, written in swift

InitialsImageView An easy, helpful UIImageView extension that generates letter initials as a placeholder for user profile images, with a randomized ba

Tom Bachant 215 Dec 17, 2022
Rounded async imageview downloader lightly cached and written in Swift

PASImageView ============ **Rounded async imageview downloader lightly cached and written in Swift 3 ** Objective-C version here Snapshot Usage //XIB

Pierre Abi-aad 173 Nov 6, 2022
SocialDownloaderApp - An exact copy of Social Downloader App by Sulton Handaya For Pelorous

SocialDownloaderApp It is a copy of Social Downloader App by Sulton Handaya For

prashant-humney 0 Jan 12, 2022
A pure Swift high-performance asynchronous image loading framework. SwiftUI supported.

Longinus Longinus is a pure-Swift high-performance asynchronous web image loading,caching,editing framework. It was learned from Objective-C web image

Qitao Yang 290 Dec 17, 2022
Asynchronous image loading framework.

YYWebImage YYWebImage is an asynchronous image loading framework (a component of YYKit). It was created as an improved replacement for SDWebImage, PIN

null 3.5k Dec 27, 2022
LCWebImage - An asynchronous image loading framework based on AFNetworking.

LCWebImage is an asynchronous image loading framework based on AFNetworking, which supports memory and disk caching, and provides functions such as custom caching, custom image decoding, and custom network configuration.

LiuChang 27 Jul 23, 2022
UIImageView BetterFace Swift

UIImageView BetterFace Swift

Croath Liu 470 Sep 9, 2022
A UIImageView extension to let the picture-cutting with faces showing better

UIImageView-BetterFace A UIImageView extension to let the picture-cutting with faces showing better Last update in v0.2_stable : add a UIImage+BetterF

Croath Liu 779 Sep 1, 2022
iOS Framework that makes it easy to preview images on any UIImageView.

AZImagePreview iOS Framework that makes it easy to preview images on any UIImageView. Screenshots Installation: Cocoa Pods: pod 'AZImagePreview' Swift

Antonio Zaitoun 25 Dec 11, 2022
Live rendering of UIImageView properties in Interface Builder

TJProfileImage Live rendering of componet’s properties in Interface Builder Features Dashed border Solid border Round corner Circle image Requirements

Tejas Ardeshna 32 Feb 28, 2022
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.

I've built out the Swift version of this library! Screenshots Description ABMediaView can display images, videos, as well as now GIFs and Audio! It su

Andrew Boryk 80 Dec 20, 2022
A lightweight generic cache for iOS written in Swift with extra love for images.

Haneke is a lightweight generic cache for iOS and tvOS written in Swift 4. It's designed to be super-simple to use. Here's how you would initalize a J

Haneke 5.2k Dec 11, 2022
PublisherKit - An open source implementation of Apple's Combine framework for processing asynchronous events over time

Publisher Kit Overview PublisherKit provides a declarative Swift API for processing asynchronous events over time. It is an open source version of App

null 5 Feb 22, 2022
CachedAsyncImage is the simplest way to add cache to your AsyncImage.

SwiftUI CachedAsyncImage ??️ CachedAsyncImage is AsyncImage, but with cache capabilities. Usage CachedAsyncImage has the exact same API and behavior a

Lorenzo Fiamingo 278 Jan 5, 2023