{"action":"opened","issue":{"url":"https://api.github.com/repos/pinterest/PINRemoteImage/issues/202","repository_url":"https://api.github.com/repos/pinterest/PINRemoteImage","labels_url":"https://api.github.com/repos/pinterest/PINRemoteImage/issues/202/labels{/name}","comments_url":"https://api.github.com/repos/pinterest/PINRemoteImage/issues/202/comments","events_url":"https://api.github.com/repos/pinterest/PINRemoteImage/issues/202/events","html_url":"https://github.com/pinterest/PINRemoteImage/issues/202","id":158380521,"number":202,"title":"PINAnimatedImage crash CGImageCreate image 0x0","user":{"login":"george-gw","id":13870100,"avatar_url":"https://avatars.githubusercontent.com/u/13870100?v=3","gravatar_id":"","url":"https://api.github.com/users/george-gw","html_url":"https://github.com/george-gw","followers_url":"https://api.github.com/users/george-gw/followers","following_url":"https://api.github.com/users/george-gw/following{/other_user}","gists_url":"https://api.github.com/users/george-gw/gists{/gist_id}","starred_url":"https://api.github.com/users/george-gw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/george-gw/subscriptions","organizations_url":"https://api.github.com/users/george-gw/orgs","repos_url":"https://api.github.com/users/george-gw/repos","events_url":"https://api.github.com/users/george-gw/events{/privacy}","received_events_url":"https://api.github.com/users/george-gw/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-03T14:31:09Z","updated_at":"2016-06-03T14:31:09Z","closed_at":null,"body":"I'm writing a prototype for an app with AsyncDisplayKit, in essence, right now, it's just an ASCollectionNode with some ASCellNodes. In the nodes, there's an ASNetworkImageNode and an ASTextNode. The displayed images could have animated gifs, I have been doing some stress test with some node manipulation (changing the text inside the nodes). And at some point the app crashed with the following message:\r\n\r\n`CGImageCreate: invalid image size 0 x 0.`\r\n\r\nYou can look at the backtrace at the end of this post.\r\n\r\nThe Podspec of AsyncDisplayKit is current using:\r\n 'PINRemoteImage/iOS', '>= 3.0.0-beta.2'\r\n\r\nI know for a fact that the images themselves are valid images as they appear in the cells before (lots of duplication of cells). I would suppose that not displaying a corrupt image is less problematic than crashing the app. So a simple 'fix' could be to change the line inside: **PINAnimatedImage.m**.\r\n\r\nFrom:\r\n```\r\n+ (CGImageRef)imageAtIndex:(NSUInteger)index inMemoryMap:(NSData *)memoryMap width:(UInt32)width height:(UInt32)height bitmapInfo:(CGBitmapInfo)bitmapInfo\r\n{\r\n  if (memoryMap == nil) {\r\n    return nil;\r\n  }\r\n  \r\n...\r\n```\r\nTo:\r\n```\r\n+ (CGImageRef)imageAtIndex:(NSUInteger)index inMemoryMap:(NSData *)memoryMap width:(UInt32)width height:(UInt32)height bitmapInfo:(CGBitmapInfo)bitmapInfo\r\n{\r\n  if (memoryMap == nil || (width == 0 && height == 0)) {\r\n    return nil;\r\n  }\r\n  \r\n...\r\n```\r\n\r\nbacktrace:\r\n```\r\n* thread #1: tid = 0x12a6bc, 0x237e4fd0 CoreFoundation`CFAutorelease + 60, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_ARM_BREAKPOINT, subcode=0xdefe)\r\n    frame #0: 0x237e4fd0 CoreFoundation`CFAutorelease + 60\r\n    frame #1: 0x006dbff8 PINRemoteImage`+[PINAnimatedImage imageAtIndex:inMemoryMap:width:height:bitmapInfo:](self=PINAnimatedImage, _cmd=\"imageAtIndex:inMemoryMap:width:height:bitmapInfo:\", index=0, memoryMap=17280104 bytes, width=0, height=0, bitmapInfo=kCGBitmapByteOrderDefault) + 656 at PINAnimatedImage.m:200\r\n    frame #2: 0x006de61e PINRemoteImage`__36-[PINSharedAnimatedImage coverImage]_block_invoke(.block_descriptor=<unavailable>) + 398 at PINAnimatedImage.m:440\r\n    frame #3: 0x006fd52a PINRemoteImage`-[PINRemoteLock lockWithBlock:](self=0x15c1ab40, _cmd=\"lockWithBlock:\", block=0x001c257c) + 142 at PINRemoteLock.m:83\r\n    frame #4: 0x006de406 PINRemoteImage`-[PINSharedAnimatedImage coverImage](self=0x15c99b80, _cmd=\"coverImage\") + 258 at PINAnimatedImage.m:438\r\n    frame #5: 0x006e00d0 PINRemoteImage`__78-[PINAnimatedImageManager animatedPathForImageData:infoCompletion:completion:]_block_invoke(.block_descriptor=0x001c27dc) + 484 at PINAnimatedImageManager.m:130\r\n    frame #6: 0x006fd52a PINRemoteImage`-[PINRemoteLock lockWithBlock:](self=0x1466a5d0, _cmd=\"lockWithBlock:\", block=0x001c27dc) + 142 at PINRemoteLock.m:83\r\n    frame #7: 0x006dfd40 PINRemoteImage`-[PINAnimatedImageManager animatedPathForImageData:infoCompletion:completion:](self=0x14671790, _cmd=\"animatedPathForImageData:infoCompletion:completion:\", animatedImageData=10401987 bytes, infoCompletion=0x001c2970, completion=0x001c2958) + 376 at PINAnimatedImageManager.m:119\r\n  * frame #8: 0x006da8d8 PINRemoteImage`-[PINAnimatedImage initWithAnimatedImageData:](self=0x15c5cc60, _cmd=\"initWithAnimatedImageData:\", animatedImageData=10401987 bytes) + 938 at PINAnimatedImage.m:57\r\n    frame #9: 0x00422176 AsyncDisplayKit`-[ASPINRemoteImageDownloader animatedImageWithData:](self=0x1465c5c0, _cmd=\"animatedImageWithData:\", animatedImageData=10401987 bytes) + 74 at ASPINRemoteImageDownloader.m:93\r\n    frame #10: 0x0041b95a AsyncDisplayKit`__49-[ASNetworkImageNode _lazilyLoadImageIfNecessary]_block_invoke.145(.block_descriptor=<unavailable>, imageContainer=10401987 bytes, error=0x00000000, downloadIdentifier=0x00000000) + 526 at ASNetworkImageNode.mm:498\r\n    frame #11: 0x0041a7e4 AsyncDisplayKit`__51-[ASNetworkImageNode _downloadImageWithCompletion:]_block_invoke_2(.block_descriptor=<unavailable>, imageContainer=10401987 bytes, error=0x00000000, downloadIdentifier=0x00000000) + 232 at ASNetworkImageNode.mm:414\r\n    frame #12: 0x00422dba AsyncDisplayKit`__93-[ASPINRemoteImageDownloader downloadImageWithURL:callbackQueue:downloadProgress:completion:]_block_invoke_2.134(.block_descriptor=<unavailable>) + 256 at ASPINRemoteImageDownloader.m:164\r\n    frame #13: 0x00d59ba6 libdispatch.dylib`_dispatch_call_block_and_release + 10\r\n    frame #14: 0x00d59b92 libdispatch.dylib`_dispatch_client_callout + 22\r\n    frame #15: 0x00d5e658 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 1684\r\n    frame #16: 0x237e37d4 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8\r\n    frame #17: 0x237e1cce CoreFoundation`__CFRunLoopRun + 1590\r\n    frame #18: 0x23730288 CoreFoundation`CFRunLoopRunSpecific + 516\r\n    frame #19: 0x2373007c CoreFoundation`CFRunLoopRunInMode + 108\r\n    frame #20: 0x24d4caf8 GraphicsServices`GSEventRunModal + 160\r\n    frame #21: 0x27e5b2c4 UIKit`UIApplicationMain + 144\r\n\r\n```"}}
{"actor":{"display_login":"george-gw"}}