[cairo] multithreaded bug in cairo on call to cairo stroke?

Bill Spitzak spitzak at gmail.com
Thu Dec 16 14:54:11 PST 2010

I would NOT try in any way to make multiple threads drawing to the same 
surface work. The locking overhead will kill Cairo performance.

The calling program can do it's own locking around drawing to a Cairo 
surface. This is how all modern api's are designed. Some older stuff 
such as stdio's mt support is from before they learned just how 
expensive a lock operation would be.

The fact that you cannot draw to two different surfaces in two threads 
is a bug that needs to be fixed. This will require locking around all 
the shared stuff (those solid colors, and I would suspect the font 
glyphs), but this would be multiple-read+single-write lock, and there 
are versions where grabbing and releasing a read lock is really fast (it 
probably does not matter how slow the write lock is).

More information about the cairo mailing list