Re: Synchronizing NSWindow updates with threads
Re: Synchronizing NSWindow updates with threads
- Subject: Re: Synchronizing NSWindow updates with threads
- From: Alastair Houghton <email@hidden>
- Date: Tue, 25 Aug 2009 21:05:58 +0100
On 25 Aug 2009, at 19:50, McLaughlin, Michael P. wrote:
I have an NSOperation app (simulation) executing one timestep at a
time.
The threads are working fairly well but the running output is
supposed to be
drawn as a color-coded map every 10 timesteps.
How fast is this in Hertz? If you're trying to update the window at
more than 60Hz, your updates will be throttled automatically by the
window server, which can make it look as if your app isn't updating
the display as often as you expect.
It seems that a window update is a low priority task because my
threads are
running and continually sending new data back to the main thread but
the
window is not updating (being redrawn) at the proper times (if at
all).
viewsNeedDisplay(), etc. does not suffice.
It's very rare that -setNeedsDisplay: is insufficient (honestly).
Usually when it is, you're trying to do something the wrong way.
Before exploring other options, I think you should check that:
1. Your main thread is running the event loop (i.e. you aren't using
it to do something else as well that is taking time away from
redrawing).
2. Your drawing code is efficient.
3. You aren't trying to redraw more than 60 times per second.
4. Whatever mechanism you are using to synchronise your data structure
isn't getting in the way of updates.
If you *really* need to force a view to display right now, you can
send it the -display message, and if you're *really, really* stuck
there's also NSGraphicsContext's -flushGraphics (or the CGContext
equivalent), but if the problem is one of the above then you may very
well find that neither of these help very much. Certainly both -
display and -flushGraphics are usually the wrong solution.
You might find the following link useful:
<http://developer.apple.com/documentation/Performance/Conceptual/Drawing/DrawingPerformance.html
>
If you're using OpenGL to redraw (which you might consider if you want
really high performance), you might also find this useful:
<http://developer.apple.com/qa/qa2004/qa1385.html>
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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