• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa window stops responding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa window stops responding


  • Subject: Re: Cocoa window stops responding
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 29 Apr 2015 01:03:37 -0500

On Apr 29, 2015, at 12:38 AM, Nisar Ahmed <email@hidden> 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 (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


References: 
 >Cocoa window stops responding (From: Nisar Ahmed <email@hidden>)
 >Re: Cocoa window stops responding (From: Uli Kusterer <email@hidden>)
 >Re: Cocoa window stops responding (From: Nisar Ahmed <email@hidden>)

  • Prev by Date: Re: Cocoa window stops responding
  • Next by Date: Where and how do I know a save completed successfully?
  • Previous by thread: Re: Cocoa window stops responding
  • Next by thread: Running AppleScripts from an App using NSAppleScript
  • Index(es):
    • Date
    • Thread