-
-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gaussian blur without border artifacts (CoreImage bug) #308
Comments
Hi, @mtrezza. Thanks for raising this issue, it is something I overlooked. In case the only difference is the "extent", I think adding an option to the existing processor should be fine. I would probably go as far as making clamping to the original image extend a default, what do you think? |
@kean sound good to me. I've implemented my previous suggestion in a live app and get these crash reports, not always but quite frequently: Crashed: NSOperationQueue 0x281e53fc0 (QOS: UNSPECIFIED) 0 CoreImage 0x18f1aa534 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 2660 1 CoreImage 0x18f1aa534 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 2660 2 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 3 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 4 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 5 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 6 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 7 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 8 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 9 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 10 CoreImage 0x18f1a9f74 CI::Context::recursive_render(CI::TileTask*, CI::Node*, CGRect const&, CI::Node*, bool) + 1188 11 CoreImage 0x18f1aa9d0 CI::Context::render(CI::ProgramNode*, CGRect const&) + 116 12 CoreImage 0x18f1c59b8 CI::create_cgimage(CI::Context*, CI::Image*, CGRect, CGColorSpace*, CI::PixelFormat, bool, unsigned long) + 2404 13 CoreImage 0x18f160360 -[CIContext(Internal) _createCGImage:fromRect:format:colorSpace:deferred:textureLimit:] + 1076 14 CoreImage 0x18f15efe4 -[CIContext createCGImage:fromRect:] + 196 15 MyApp 0x1030bcefc specialized ImageProcessor.GaussianBlurClampedToExtent.process(image:context:) + 235 (RemoteMediaManager.swift:235) 16 Nuke 0x103d879c4 $s4Nuke13ImagePipelineC07processB033_64FA2D582EFB9D605832F3421CEE67ADLL_11isCompleted3for9processor3jobyAA0B8ResponseC_SbAA0B7RequestVAA0B10Processing_pAA4TaskC3JobCyAkC5ErrorO_GtFyycfU_So7UIImageCSgAWXEfU_TA + 112 17 Nuke 0x103da448c $s4Nuke13ImageResponseC3mapyACSgSo7UIImageCSgAGXEFAEyXEfU_ + 40 18 Nuke 0x103d87a14 $s4Nuke13ImageResponseCSgs5Error_pIgozo_ADsAE_pIegrzo_TRTA + 24 19 libswiftObjectiveC.dylib 0x1036decec autoreleasepool(invoking:) + 4392201452 20 Nuke 0x103d803dc $s4Nuke13ImagePipelineC07processB033_64FA2D582EFB9D605832F3421CEE67ADLL_11isCompleted3for9processor3jobyAA0B8ResponseC_SbAA0B7RequestVAA0B10Processing_pAA4TaskC3JobCyAkC5ErrorO_GtFyycfU_ + 1252 21 Nuke 0x103d7b7a8 $sIeg_IeyB_TR + 28 22 Foundation 0x18a4ee82c __NSBLOCKOPERATION_IS_CALLING_OUT_TO_A_BLOCK__ + 16 23 Foundation 0x18a3f6a28 -[NSBlockOperation main] + 72 24 Foundation 0x18a3f5efc -[__NSOperationInternal _start:] + 740 25 Foundation 0x18a4f0700 __NSOQSchedule_f + 272 26 libdispatch.dylib 0x1894996c8 _dispatch_call_block_and_release + 24 27 libdispatch.dylib 0x18949a484 _dispatch_client_callout + 16 28 libdispatch.dylib 0x189470e14 _dispatch_continuation_pop$VARIANT$armv81 + 404 29 libdispatch.dylib 0x1894704f8 _dispatch_async_redirect_invoke + 592 30 libdispatch.dylib 0x18947cafc _dispatch_root_queue_drain + 344 31 libdispatch.dylib 0x18947d35c _dispatch_worker_thread2 + 116 32 libsystem_pthread.dylib 0x18967c17c _pthread_wqthread + 472 33 libsystem_pthread.dylib 0x18967ecec start_wqthread + 4 Crashed: com.github.kean.Nuke.ImagePipeline 0 libswiftFoundation.dylib 0x1b2cddf24 specialized __DataStorage.init(bytes:length:copy:deallocator:offset:) + 448 1 libswiftFoundation.dylib 0x1b2c000fc Data.InlineSlice.ensureUniqueReference() + 188 2 libswiftFoundation.dylib 0x1b2cde574 specialized Data.InlineSlice.append(contentsOf:) + 48 3 libswiftFoundation.dylib 0x1b2cdf4d4 specialized Data._Representation.append(contentsOf:) + 320 4 Nuke 0x1036cc8c8 $s4Nuke13ImagePipelineC19imageDataLoadingJob33_64FA2D582EFB9D605832F3421CEE67ADLL_7context010didReceiveE08response8signpostyAA4TaskC0G0Cy10Foundation0E0V_So13NSURLResponseCSgtAC5ErrorO_G_AC08OriginalbE12FetchContextAELLCAprA8SignpostCtF + 1008 5 Nuke 0x1036cf6b8 $s4Nuke13ImagePipelineC04loadB4Data33_64FA2D582EFB9D605832F3421CEE67ADLL3for7context6finishyAA4TaskC3JobCy10Foundation0E0V_So13NSURLResponseCSgtAC5ErrorO_G_AC08OriginalbE12FetchContextAELLCyyctFyAO_AQtcfU_yycfU_TA + 36 6 Nuke 0x1036c37a8 $sIeg_IeyB_TR + 28 7 libdispatch.dylib 0x18483ca38 _dispatch_call_block_and_release + 24 8 libdispatch.dylib 0x18483d7d4 _dispatch_client_callout + 16 9 libdispatch.dylib 0x1847e6324 _dispatch_lane_serial_drain$VARIANT$mp + 592 10 libdispatch.dylib 0x1847e6e40 _dispatch_lane_invoke$VARIANT$mp + 428 11 libdispatch.dylib 0x1847ef4ac _dispatch_workloop_worker_thread + 596 12 libsystem_pthread.dylib 0x184a1e114 _pthread_wqthread + 304 13 libsystem_pthread.dylib 0x184a20cd4 start_wqthread + 4 I am using Nuke to load images into a |
Are there any messages in the console from Core Image aside from the stack trace? I found similar crash reports online pinterest/PINRemoteImage#109, but so far no solutions. |
@kean I did not see any other CoreImage related errors in the logs. I’ve reached out to Apple and the engineer said that it may either be a threading issue or indeed a CImage bug. |
By default,
|
I filed a bug report with Apple. An Apple engineer suggested that the recursive stack trace is likely an indication that the indefinitely extended edges may cause the crash in CIImage. I’ll update here. |
Hi, @mtrezza. Did you receive any updates from Apple regarding this issue? |
@kean Unfortunately not. I think looking for an alternative to The challenge would be to find a correct |
For the blur matrix of But that does not seem to be the case. The extent change of So for Anyway, instead of
After the new app release I will update here if that fixed the crashes. |
The crashes still occur with the solution above, specifically:
That looks like the app is trying to access an already deallocated object. Either the issue still occurs because of still using As a next step I am removing any change to the image before blurring it to see if the issue is related to clamping by removing the line |
With the changes described in my previous comment, the crashes still occur. Therefore I assume the issue is unrelated to |
Sorry, instead of closing I think we can address the original issue of gray border artifacts when blurring. Since the crashes are unrelated to
@kean what do you think? |
Update after a call regarding the issue with an Apple engineer who works on the CoreImage team: The issue has been observed across different applications which leads to assume a CoreImage bug, but Apple hasn't been able to nail it down quite yet. The crash seems almost certainly related to resource constraints especially when many CoreImage contexts are created in parallel (for example blurring images on-the-fly as they appear in a UICollectionView) or the images to process are large in size. The workaround I am trying now is to significantly downsample images to a few pixels then blurring them with a very low radius - visually it leads to the same result and there are no crashes reported yet. |
Hey, @mtrezza. I would appreciate if you could add a "clamp to extent" option to the existing |
Since it appears to be a Core Image bug, I'm going to close it. If you have other idea, please let me know. |
This is not a bug, the method is not correct, gaussian loose image border proportionally to gaussian radius natively!
|
Cool, makes sense. I will appreciate a pull request. I'm using this processor myself, so the help is welcome. If not, I can test and merge it later myself. Thanks. |
Hello, @kean, is this case still not progressing? are there any plans for this? |
Any plans to fix this issue? I wanted to add glow to my image by repeating and blurring the same image in ZStack. Unfortunately, |
Issue
Gaussian blur
CIFilter
naturally creates gray artifacts at the borders of the output image.A common use case when blurring an image would be avoiding these artifacts.
Proposed solution
Add a new filter that extends the edge pixels indefinitely and crop the image to its original extend after blurring.
Alternative solutions
Extend existing
GaussianBlur
filter with a BooleanclampToExtend
option:"com.github.kean/nuke/gaussian_blur?radius=\(radius)&clampToExtend=\(clampToExtend)"
The text was updated successfully, but these errors were encountered: