My app uses GTK3. It runs fine on Kubuntu 24.04 and Raspberry Pi OS 12, but I am worried about support for the backend.
First question: Is there a way to determine what backend my application is actually using? Should I assume that it is running x11 unless I tell it otherwise? If I tell it otherwise, can I assume that it is actually using what I specified?
Second question: I read that I can specify the backend to use on the command line. To find out what backends are supported, I am supposed to specify “help” as the backend:
GDK_BACKEND=help python myapplication.py
The output declares support for x11, wayland, and broadway on both platforms. On Kubuntu, I can run
GDK_BACKEND=x11 python myapplication.py
but if I specify either of the other two “supported” backends, the program crashes with
Gtk-CRITICAL **: 09:25:14.487: _gtk_css_lookup_resolve: assertion ‘(((extension ({ GTypeInstance __inst = (GTypeInstance) ((provider)); GType __t = ((_gtk_style_provider_private_get_type ())); gboolean __r; if (!__inst) __r = (0); else if (__inst->g_class && __inst->g_class->g_type == __t) __r = (!(0)); else __r = g_type_check_instance_is_a (__inst, __t); __r; }))))’ failed
/usr/lib/python3/dist-packages/gi/overrides/init.py:313: Warning: g_object_set_data_full: assertion ‘G_IS_OBJECT (object)’ failed
return super_init_func(self, **new_kwargs)(wax.py:3269): Gtk-ERROR **: 09:25:14.488: Can’t create a GtkStyleContext without a display connection
Trace/breakpoint trap (core dumped)
On Raspberry Pi OS, I get the same list of “supported” backends. x11 and wayland work, but broadway produces the same crash.
I would love to be able to use broadway, but it has never worked reliably for me. However, it seems important that I be able to specify wayland when the program is running on a platform that uses wayland. Considering that my program crashes on Kubuntu 24.04 when I specify wayland, I suppose that Kubuntu must be running x11. I believe that wayland is optional in 24.04 (and standard in 24.10), but as far as I know I have done nothing to exercise the option. However, I am pretty sure that Raspberry Pi OS 12 uses wayland by default. Is it possible that GTK detects that Raspberry Pi OS supports wayland and automatically configures itself to use the wayland backend, or do I need to tell it explicitly to use wayland?