SDWebImage: Crash at SDAnimatedImage initWithData:scale:options

New Issue Checklist

Issue Info

Info Value
Platform Name ios
Platform Version 14.x / 15.x
SDWebImage Version 5.12
Integration Method cocoapods
Xcode Version Xcode 12 / Xcode 13
Repro rate 0.5% - 1%

Issue Description and Steps

We are seeing a significant increase in volume for OOM crashes while initializing animated images. Our stack uses mostly webp images.

Any ideas?

Fatal Exception: NSInvalidArgumentException
*** NSAllocateMemoryPages(1038998) failed

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x129dc0 __exceptionPreprocess
1  libobjc.A.dylib                0x287a8 objc_exception_throw
2  Foundation                     0x13c234 NSZoneMalloc
3  Foundation                     0xecf4 -[_NSPlaceholderData initWithBytes:length:copy:deallocator:]
4  Tumblr                         0x128118c -[SDAnimatedImage initWithData:scale:options:] + 127 (SDAnimatedImage.m:127)
5  Tumblr                         0x12969cc SDImageLoaderDecodeImageData + 80 (SDImageLoader.m:80)
6  Tumblr                         0x12a0fcc __70-[SDWebImageDownloaderOperation URLSession:task:didCompleteWithError:]_block_invoke.244 + 528 (SDWebImageDownloaderOperation.m:528)
7  Foundation                     0x132f88 __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__
8  Foundation                     0x20628 -[NSBlockOperation main]
9  Foundation                     0x1353b0 __NSOPERATION_IS_INVOKING_MAIN__
10 Foundation                     0x202b0 -[NSOperation start]
11 Foundation                     0x135e54 __NSOPERATIONQUEUE_IS_STARTING_AN_OPERATION__
12 Foundation                     0x1358e0 __NSOQSchedule_f
13 libdispatch.dylib              0x13484 _dispatch_block_async_invoke2
14 libdispatch.dylib              0x481c _dispatch_client_callout
15 libdispatch.dylib              0x7cf4 _dispatch_continuation_pop
16 libdispatch.dylib              0x7440 _dispatch_async_redirect_invoke
17 libdispatch.dylib              0x15fe0 _dispatch_root_queue_drain
18 libdispatch.dylib              0x167d8 _dispatch_worker_thread2
19 libsystem_pthread.dylib        0x3768 (Missing)
20 libsystem_pthread.dylib        0xa74c (Missing)

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Fixed in 5.15.1

Well, I think a a failed image is way better than a crash. Might be a good idea for a temporary fix?

Experience the same problem here with the “.gif” images. Did you find a way to fix it or what is the reason of the problem?