GPUImage icon indicating copy to clipboard operation
GPUImage copied to clipboard

Applying filter in NSBlockOperation crashes app

Open kissfro opened this issue 12 years ago • 2 comments

I have the following bit of code which produces a little sample thumbnail of an image with an applied filter:

NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:
^{
    UIImage *image = [filterItem.thumbnailFilter imageByFilteringImage:self.thumbnail];
    [[NSOperationQueue mainQueue] addOperationWithBlock:
     ^{
         SubmenuScrollViewTableViewCell *validSubmenuScrollViewTableViewCell = (SubmenuScrollViewTableViewCell*)[self.tableView cellForRowAtIndexPath: indexPath];
         validSubmenuScrollViewTableViewCell.imageView.image = image;
         [validSubmenuScrollViewTableViewCell.activityIndicatorView stopAnimating];
         [validSubmenuScrollViewTableViewCell setNeedsLayout];
     }];
}];

It seems with the second to latest build, it is now causing a crash. I'm wondering, is this something I should've just avoided doing in the first place and now it's caught up with me, or is it a bug? Below is a crash report:

Thread : Crashed: com.sunsetlakesoftware.GPUImage.openGLESContextQueue 0 AGXGLDriver 0x0000000182ee7cc0 void twiddleBlock<AGXUConverterPassThru<true, 4ul, 1u>, true, true>(void const_, void const_, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned int, unsigned int, unsigned int, unsigned int) 1 AGXGLDriver 0x0000000182ee7c90 void twiddleBlock<AGXUConverterPassThru<true, 4ul, 1u>, true, true>(void const_, void const_, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned int, unsigned int, unsigned int, unsigned int) 2 AGXGLDriver 0x0000000182ee778c void agxuBlockTwiddleAddressImpl<AGXUConverterPassThru<true, 4ul, 1u> >(void_, void_, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned int, unsigned int, unsigned int) 3 AGXGLDriver 0x0000000182edeb6c void agxuBlockTwiddleAddress<AGXUConverterPassThru<true, 4ul, 1u> >(void_, void_, unsigned int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned int, unsigned int, unsigned int, agxsTwiddledBlockInfo_) 4 AGXGLDriver 0x0000000182ecb7d0 AGXTextureRec::setTexImage(GLDShareGroupRec_, void const_, AGXGLTextureDesc const_, AGXTexSubImageDesc const*) 5 AGXGLDriver 0x0000000182ecdadc glrWriteTextureData 6 libGPUSupportMercury.dylib 0x00000001897cea48 gldModifyTexSubImage 7 GLEngine 0x0000000186a57d80 glTexImage2D_Exec 8 OpenGLES 0x0000000186b23afc glTexImage2D + 108 9 Filter Sample 0x000000010024037c __55-[GPUImagePicture initWithCGImage:smoothlyScaleOutput:]_block_invoke + 184 10 libdispatch.dylib 0x000000019080c3e0 _dispatch_client_callout + 16 11 libdispatch.dylib 0x0000000190811f2c _dispatch_barrier_sync_f_invoke + 48 12 Filter Sample 0x000000010023d934 runSynchronouslyOnVideoProcessingQueue + 124 13 Filter Sample 0x0000000100240270 -[GPUImagePicture initWithCGImage:smoothlyScaleOutput:] + 944 14 Filter Sample 0x000000010023fe18 -[GPUImagePicture initWithCGImage:] + 32 15 Filter Sample 0x00000001002348f0 -[GPUImageFilter newCGImageByFilteringCGImage:orientation:] + 72 16 Filter Sample 0x000000010023edc4 -[GPUImageOutput imageByFilteringImage:] + 128 17 Filter Sample 0x00000001001be614 -FiltersSubmenuScrollView createThumbnailForItem: 18 Filter Sample 0x00000001001bc47c __53-[SubmenuScrollView tableView:cellForRowAtIndexPath:]_block_invoke (SubmenuScrollView.m:198) 19 Foundation 0x0000000184d73e04 -[NSBlockOperation main] + 76 20 Foundation 0x0000000184d60d38 -[__NSOperationInternal _start:] + 644 21 Foundation 0x0000000184e22d7c __NSOQSchedule_f + 76 22 libdispatch.dylib 0x000000019080c3e0 _dispatch_client_callout + 16 23 libdispatch.dylib 0x0000000190811930 _dispatch_async_redirect_invoke + 152 24 libdispatch.dylib 0x000000019080c3e0 _dispatch_client_callout + 16 25 libdispatch.dylib 0x00000001908133fc _dispatch_root_queue_drain + 400 26 libdispatch.dylib 0x0000000190813638 _dispatch_worker_thread2 + 76 27 libsystem_pthread.dylib 0x00000001909a1918 _pthread_wqthread + 356

kissfro avatar Mar 18 '14 06:03 kissfro

Note: I edited my original message and changed it to reflect the fact that this is not only limited to 64 bit devices, but so far has happened on all iphone5 and above on ios7 and above. Also, didn't realize you just pushed an update, so this was not the most recent build, but the one before it.

In my last app update, I changed the deployment target of GPUImage to 6.0, and comment out the deallocation block of code that was giving an error. After that is when all this started to happen.

I'm wondering if just going back to deployment target of ios4 and not using arm64 so I don't have to comment out that one line of code which seems to involve a semaphore, if that will fix the problem.

kissfro avatar Mar 18 '14 20:03 kissfro

Actually it appears this problem has nothing to do with arm64 as I reverted back to ios4 and reinstated that deallocation method in GPUImagePicture and am still getting the problem. Appears something changed between the version I was using previously (from mid September) to the newest version that causes a problem you do a filter on a block.

kissfro avatar Mar 21 '14 00:03 kissfro