Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applications do not start with "cannot register existing type 'GtkIMContext'" #651

Open
SyntevoAlex opened this issue Nov 2, 2020 · 14 comments

Comments

@SyntevoAlex
Copy link

SyntevoAlex commented Nov 2, 2020

This problem was mentioned in other issues:
#565
#580
#584

However, none seem to have arrived at solution, and in general strayed in some other direction, so I decided to post a new issue.

When an effected application is started, it prints errors to console and fails to start UI:

GLib-Object-WARNING **:   15:47:30.680: cannot register existing type 'GtkIMContext'
GLib-CRITICAL **:         15:47:30.680: g_once_init_leave: assertion 'result != 0' failed
GLib-GObject-CRITICAL **: 15:47:30.680: g_type_register_dynamic: assertion 'parent_type > 0' failed
GLib-GObject-CRITICAL **: 15:47:30.680: g_object_new_with_properties: assertion 'G_TYPE_IS_OBJECT (object_type)' failed

I have debugged the problem and found that this is because HIME module for GTK3 is incorrectly linked to GTK2 libraries:

$ readelf -d /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-hime.so
...
0x0000000000000001 (NEEDED)             Shared library: [libgtk-x11-2.0.so.0]
...

The problem develops as follows:

  1. Affected application calls gtk_im_multicontext_get_type() or gtk_im_context_get_type().
  2. This calls gtk_im_context_get_type_once(), which creates the type and saves "did that" flag in GTK3.
  3. HIME also calls gtk_im_context_get_type() from gtk_im_context_hime_register_type().
  4. This time, it's called from GTK2, because HIME is linked to GTK2 libraries.
  5. GTK2 doesn't yet have "did that" flag and tries to register it again, causing a GLib-Object-WARNING.

When building HIME from sources, the problem is fixed and HIME is linked to GTK3.
I understand that the problem is possibly fixed by the following commit: abf244a

@xatier
Copy link
Contributor

xatier commented Nov 3, 2020

Hi @SyntevoAlex , thanks for the bug report. I wonder which version/environment the bug occured?

In abf244a, noticed that I used = instead of +=, which would re-assign GTKINC and LDFLAG. If possible, please consider using the latest source, which I have quite a few fixes here and there.

I'm personally using HIME build from trunk on Archlinux, just FYI.

@SyntevoAlex
Copy link
Author

SyntevoAlex commented Nov 3, 2020

The problem for example occurs on Ubuntu 20.04, which has version 0.9.10+git20170427

Building from sources fails:

win-kbm.c:249:8: error: unknown type name ‘GtkStatusIcon’
249 | extern GtkStatusIcon *tray_icon;

I was able to work around that by only building src/im-client and src/gtk3-im. After that, the problem is no longer reproducible, and readelf -d /usr/lib/x86_64-linux-gnu/gtk-3.0/3.0.0/immodules/im-hime.so confirms that HIME is now correctly linked against GTK3.

I am myself not a user of HIME, but a developer of a product which fails to start with HIME installed :(

@xatier
Copy link
Contributor

xatier commented Nov 3, 2020

I see. Thanks for providing the detailed info.
Unfortunately the ubuntu/debian package maintainer of HIME is not active. Let me see if I can bring someone to help upgrade the package to the latest ver.

@SyntevoAlex
Copy link
Author

Thanks!

@xatier
Copy link
Contributor

xatier commented Nov 3, 2020

Hey @medicalwei ... would you please take a look? 🙏 I'm not familiar with Ubuntu/Debian ecosystems. 😢

@xatier
Copy link
Contributor

xatier commented Nov 3, 2020

@SyntevoAlex if all we need is the .deb package, please refer to the CI script:

https://github.com/hime-ime/hime/blob/master/distro/debian/ci/entrypoint.sh

@SyntevoAlex
Copy link
Author

Unfortunately for me it's more complicated - as a developer of other product that gets broken by HIME, I'm interested in having fixed HIME for all other users. This basically means updating it in Ubuntu (and other Linux where necessary).

@medicalwei
Copy link
Contributor

I am not actually maintaining hime in Debian.

However, as soon as I got my computer back on Thursday I can try building it. Please keep me posted!

@xatier
Copy link
Contributor

xatier commented Nov 3, 2020

@czchen would you be able to help on Debian side? 🙏

@SyntevoAlex
Copy link
Author

@tmssngr FYI

@medicalwei
Copy link
Contributor

Hi,

Do you plan to release a new version using tag or release? Or, where do you put your release tarball?

@xatier
Copy link
Contributor

xatier commented Nov 8, 2020

@medicalwei thanks for taking care of this. I just tagged v.0.9.11.

@medicalwei
Copy link
Contributor

I will handle the package uploading soon.

@xatier
Copy link
Contributor

xatier commented Dec 30, 2020

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants