Re: NSWindow not redrawing subviews
Re: NSWindow not redrawing subviews
- Subject: Re: NSWindow not redrawing subviews
- From: Ken Thomases <email@hidden>
- Date: Sat, 07 Jan 2017 01:55:58 -0600
On Jan 7, 2017, at 12:59 AM, Tamas Nagy <email@hidden> 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 (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