Makes sense, thanks Ken!

> On 2017. Jan 7., at 8:55, Ken Thomases <k...@codeweavers.com> wrote:
> 
> On Jan 7, 2017, at 12:59 AM, Tamas Nagy <tamas.lov.n...@gmail.com> wrote:
>> 
>> This is a video mixer app. There are multiple windows for controlling 
>> layers, effects, etc. Rendering is done on a CVDisplayLink thread by OpenGL. 
>> Whenever I need to update something on the UI from that CVDisplayLink thread 
>> I call dispatch_async(dispatch_get_main…).
>> 
>> But double-checking my code I found sometimes I call [NSSlider cell] 
>> setFloatValue:] from the CVDisplayLink thread followed by a 
>> setNeedsDisplayInRect… on the main thread, but [NSSlider cell] 
>> setFloatValue:] might be already calling setNeedsDisplay…? Than it could be 
>> the reason of the problem I guess.
> 
> Yes, I would expect -setFloatValue: to call a -setNeedsDisplay… method and 
> therefore it's not valid to call it from a background thread.
> 
>> Hmm, I should double-check if drawing is always happening from the main 
>> thread. What is the common way to do that? Can Instruments helpful to debug 
>> that? 
> 
> I'm not aware of any comprehensive way of doing that.
> 
> For calls to -setNeedsDisplay… methods, you can try overriding 
> -setViewsNeedDisplay: in your window subclass and doing NSAssert([NSThread 
> isMainThread], @"views marked as needing display from non-main thread") 
> before calling through to super.  Of course, make sure assertions are enabled 
> for your build configuration.
> 
> Regards,
> Ken
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to