Re: NSImage drawInRect deadlock
Re: NSImage drawInRect deadlock
- Subject: Re: NSImage drawInRect deadlock
- From: Jens Alfke <email@hidden>
- Date: Mon, 08 Aug 2016 13:48:52 -0700
> On Aug 8, 2016, at 12:46 PM, Aaron Tuller <email@hidden> wrote:
>
> Search for NSImage here:
>
> https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-126728 <https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/Multithreading/ThreadSafetySummary/ThreadSafetySummary.html#//apple_ref/doc/uid/10000057i-CH12-126728>
>
All it says about NSImage is: "One thread can create an NSImage object, draw to the image buffer, and pass it off to the main thread for drawing. The underlying image cache is shared among all threads.”
So it sounds like the problem isn’t the new NSImage but the existing one being drawn into it. It might help to get the NSImage’s imageRep on the main thread and then pass that to the background thread.
(I’ve got some similar code in one of my apps that creates NSImages on a parallel dispatch queue and draws into them, but it only draws text, not any pre-existing images. This code works fine even with dozens of tasks at a time.)
—Jens
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden