@civodul I haven't seen this myself but I wonder if it's related to the ancient slap-fight between Emacs and GTK over how X connections are supposed to work. Can you conveniently try an Xaw build of Emacs?
(see https://gitlab.gnome.org/GNOME/gtk/-/issues/221 and https://gitlab.gnome.org/GNOME/gtk/-/issues/2315 )