This upstream commit https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/5608 fixed the issue, I will backport it.