• 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
Issues with multithreaded drawing in Cocoa?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issues with multithreaded drawing in Cocoa?


  • Subject: Issues with multithreaded drawing in Cocoa?
  • From: email@hidden
  • Date: Wed, 10 Dec 2003 03:03:39 -0500

Greetings,

I'm having this problem in a multithreaded Cocoa app I'm writing in which multiple successive calls to
- [NSView setNeedsDisplayInRect:]
are not all being drawn.

I made a sample project, but discovered that the problem did not appear on all machines with the same parameters (though it does on most). What happens specifically is that if a separate thread is rapidly sending many distinct setNeedsDisplayInRect messages to the view, in some cases the rects sent are not drawn.

The problem probably lies in the calling of setNeedsDisplayInRect from one thread while another thread is in that view's drawRect method. When this occurs, *sometimes* the area will be marked as needing to be displayed, and sometimes it won't. Or so it seems.

Any thoughts? I can post the sample code somewhere if it'll be helpful. Has anyone else experienced the same issue? I don't feel like putting locks around my drawing code, though if that's what I have to do...

I recall reading in the docs somewhere that Cocoa drawing is thread-safe. Is there something I'm missing?


Thanks!

J.D. Zamfirescu
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Is there a Java version of SGDataProc?
      • From: "ZhaoYu" <email@hidden>
  • Prev by Date: Re: best way to save document level settings?
  • Next by Date: Thanks for the tableview help
  • Previous by thread: Custom Checkbox NSButtons in TableViews à la i Cal (how to?)
  • Next by thread: Is there a Java version of SGDataProc?
  • Index(es):
    • Date
    • Thread