Abhi Beckert
Abhi Beckert

Reputation: 33359

Debug thread safety issue on iOS

I've got a thread safety bug somewhere in a fairly large set of code. It's reproducible as a random crash simply by scrolling around in my CATiledLayer for a few seconds in the simulator, and solvable by locking my drawing code into a single thread (which is not ideal, since CATiledLayer is designed to be multi-threaded and my drawing code is slow enough to need it).

How do I go about debugging a thread safety issue? I suspect it's somewhere in my code to lazily fetch (and cache) the data which is being drawn, but that doesn't narrow it down much.

I've skim read the Concurrency Programming Guide, but don't see anything that talks about debugging, it just talks about how to structure your code.

Upvotes: 1

Views: 848

Answers (1)

Kyr Dunenkoff
Kyr Dunenkoff

Reputation: 8090

Which concurrency method do you use? GCD or NSThread? And if I can't convince you to use single thread for drawing, try to use @syncronized in your setter/getter methods (or atomic properties, if you use synthesized setters/getters).

Upvotes: 1

Related Questions