Re: Simulator restriction?
Re: Simulator restriction?
- Subject: Re: Simulator restriction?
- From: Luca Ciciriello <email@hidden>
- Date: Wed, 29 Feb 2012 21:02:04 +0100
Thanks David for your clear explanation. I'm new to Core Graphics.
Today I have changed my approach, and as you have now suggested, I've used a for..in loop.
Now all works fine.
Thanks again.
Luca.
On Feb 29, 2012, at 8:51 PM, David Duncan wrote:
> 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