• 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: Simulator restriction?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simulator restriction?


  • Subject: Re: Simulator restriction?
  • From: David Duncan <email@hidden>
  • Date: Wed, 29 Feb 2012 11:51:41 -0800

This will never work.

Technically the issue is that a CGContext is not designed to be accessed from multiple threads at the same time (it is safe to use in a thread-confied manner, which means one thread at a time) but you are asking for usage across multiple threads. If this works on device, I can only imagine it is because GCD is only using a single thread to do the work (either because you are on a single-threaded device, or because GCD doesn't see a point in spawning another thread to run a parallel queue). In the simulator however, you always have more cores available than you do on device, hence GCD is almost certainly going to spawn more of them and cause your problems.

Practically however, what you are asking for is undefined drawing (given your dispatch to a concurrent queue). Since the block execution order in dispatch_apply is going to be undefined, you may theoretically see the results in any execution order, which results in the content overlapped in different orders based entirely on the execution state of the device at any given time.

As for your actual code, your CGContextStrokePath() call is doing nothing (because once you call FilEllipseInRect(), the current path is empty). What you actually want is to call AddEllipseInRect, followed by DrawPath(), with the FillStroke constant. Also you should use SetFillColorWithColor() instead of SetFillColor() coupled with CGColorGetComponents(). And of course, you should do this all on the same thread as your -drawRect: method is executing on, which basically means you shouldn't bother with the dispatch_apply and just use a for..in loop.

On Feb 29, 2012, at 1:16 AM, Luca Ciciriello wrote:

> I've found a behavior discrepancy between simulator and device (iPad) when I use some graphic functionality and Grand Central Dispatch.

--
David Duncan


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Simulator restriction?
      • From: Luca Ciciriello <email@hidden>
References: 
 >Simulator restriction? (From: Luca Ciciriello <email@hidden>)

  • Prev by Date: Re: Xcode - An Apple Embarrassment
  • Next by Date: Re: Simulator restriction?
  • Previous by thread: Re: Simulator restriction?
  • Next by thread: Re: Simulator restriction?
  • Index(es):
    • Date
    • Thread