[cairo] cairo 1.10 multithreading problems

Sven Goericke sgoericke at vandalay.org
Sun Oct 24 22:25:08 PDT 2010


it seems that with version 1.10 something has changed about
thread-safety. In fact, I'm no longer able to run my cairo-drawing
threads simultanous. It had worked fine including the latest 1.8.10
version but now something is wrong.

I work on a addon for the X-Plane simulator (so i work on a shared
object/dylib/DLL). I use the image-backend (drawing in memory) and then
create an OpenGL Texture. Until now i used up to 8 Threads to draw the
Flight Instrument Displays.

It works like that:

Every Display is registered on the X-Plane main-loop as a
callback-function. Also each of that function has it's own
drawing-thread. Whole redrawing of the Displays at every frame isn't
required, so some of the drawing-threads are almost in waiting-state.
What i have is

Callback A --> Thread A
Callback B --> Thread B

Each Callback uses it's own mutex and condition variable. There is no
data shared between the different threads (they all have it's own cairo
contexts etc.).

This approach no longer works with cairo 1.10. Sooner or later X-Plane
crashes (with different signals and different function-calls). The only
way i got it working for now is to use one global mutex (drawing threads
no longer running simultanous). However, this means a large performance hit.

As a summary: cairo crashes if running multiple threads simultanous.
There is no specific cairo-function which causes the crash. I had
crashes on cairo_stroke(), cairo_fill(), cairo_show_text(),
cairo_paint()... Also i got different signals from the OS (SIGABRT,
SIGSEGV, SIGILL). I use the cairomm C++ Bindings. Also i tried different
versions of cairomm and pixman, no luck. If i use cairo 1.8.10 all is fine.

Tested on Linux (archlinux i686) and MacOS 10.6 (cairo etc. compiled
with "-arch i386". I use boost::thread etc. On Win32 cairo 1.10 works
well (all libraries compiled with MSVC from Visual Studio 2008).

Any Ideas?

More information about the cairo mailing list