[Openmcl-devel] Techniques for identifying Cocoa API calls that should be run on GUI thread
Clayton Stanley
cstanley at cstanley.no-ip.biz
Mon Mar 10 12:19:55 PDT 2014
I have a Cocoa application built with Clozure and the Objective-C bridge
that has been developed over the course of ccl-1.8-ccl-2.0 and OS X 10.6.8
- OS X 10.9.2. It seems that every time I upgrade OS X I find new areas of
the code that use the Objective-C bridge that crash due to not being thread
safe. Basically, I have to identify new areas in the code that I need to
wrap with '(easygui::running-on-main thread () ...)' in order to keep
things from crashing.
On the one hand, I'm happy that my testing environment works well enough to
identify these new issues during testing. On the other hand, it's not very
satisfying to have the tests fail every time I upgrade OS X due to new
threading issues.
I would like to be able to better identify areas in the code that might
have threading issues (i.e., that need to be run on the GUI thread), so
that I can clean things up before tests start to fail, so that I have a
better chance to have an error-free upgrade when moving to a new OS X
version.
For developers with a lot of experience with Cocoa/Objective-C/Clozure, how
have you identified these areas? Are there any static/dynamic analysis
tools or debugging flags that can identify trouble spots before crashes
happen?
If you identify trouble spots by simply running the code and testing (like
I'm doing currently), when a crash occurs, how do you troubleshoot where
the threading issue lies? On my setup when a threading issue occurs, I do
not get very informative feedback; the GUI thread hangs, the slime thread
seems to hang, I don't see anything useful in Console.app, etc. So it's
basically just divide-and-conquer of the testing code (and restarting
slime/:cocoa each time, grrr) until I can identify the trouble area.
Maybe the 'right' way is for me to better understand how cocoa works, so
that I can use that conceptual understanding to have a better sense where
trouble spots might be when writing code. If that's the case,
recommendations on reading material would be very helpful.
Thanks for the tips,
-Clayton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20140310/946f9cdd/attachment.htm>
More information about the Openmcl-devel
mailing list