Is rendering in Gtk4 thread safe?

I looked around for statements and couldn’t find something and then looked at the code and i’m still not sure if this is possible.

If i create a snapshot and build a rendering node tree in a background thread, can i pass the pointer and use it in the GUI thread ? I did some small tests and it works fine.

But there is one point where i am not sure. Its the rendering of Pango Text. While glyph runs are copied the PangoFont is passed around by reference. Everything immutable and copied should be very thread safe.

Is getting the Pango Context (which contains the FontMap) from the widget and then using it to create Text Render notes in a background thread fine?

I remember that about 10 years ago there were some thread issues with the Pango fonts. But i can’t duckduckgo anything recently disussed.

You are right that fonts are the big question here. I would be much happier if we used a hb_font_t here instead of a PangoFont.

Passing a font map to a different thread is the one thing that isn’t guaranteed to be threadsafe (its a cache, and updating it isn’t threadsafe). The default font map api is threadsafe by means of having separate per-thread instances. But passing a PangoFont between threads should be ok.