On Apr 29, 2015, at 12:38 AM, Nisar Ahmed <nisar....@gmail.com> wrote:
> I think I have found the culprit, I have subclassed NSOpenGLView where in > drawRect, I am rendering a IOSurface based texture using CVDisplayLink, > although I don't know why it is causing the screen to freeze but when I > moved the rendering code from CVDisplayLink to dispatch timer the problem > seems to have disappeared. Inside CVDisplay callback I was calling [view > setNeedsDisplay:YES] which I think is a correct way of calling drawRect > from background thread? No. You should shunt the call to -setNeedsDisplay: to the main thread. Use an asynchronous mechanism to do so, though (e.g. dispatch_async(dispatch_get_main_queue(), …)); avoid blocking the display link thread. > while inside timer I am directly calling [view > drawRect:NSZeroRect]. It is never correct to call a view's -drawRect: like that. If you need to a view to draw itself immediately, you can call -display. However, you generally shouldn't do that, either. Just call -setNeedsDisplay: from your timer, if you're going to use a timer. But better to continue to use CVDisplayLink. 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