monome / norns

norns is many sound instruments.
http://monome.org
GNU General Public License v3.0
633 stars 147 forks source link

cairo thread safety #466

Closed catfact closed 5 years ago

catfact commented 6 years ago

thread safety in cairo (or the lack thereof) is a little unclear to me. it is supposed to generally be reentrant: https://bugs.freedesktop.org/show_bug.cgi?id=74355 https://stackoverflow.com/questions/25726017/is-the-cairo-graphics-library-reentrant

but perhaps it isn't, or we aren't using it correctly, since there has been a report of this error when running the startup animation along with redraws from lua scripts:

matron: ../../../../src/cairo-pattern.c:1125: cairo_pattern_destroy: Assertion `CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&pattern->ref_count)' failed.

( caveat: this error hasn't been noticed on norns hardware, only on rpi3 + push2 setup. )

if we can't call to the same cairo_t and cairo surface from different threads, then perhaps the most robust solution is to use the event loop for screen drawing requests.

other options:

tehn commented 5 years ago

revisited in #777