from gi.repository import Gtk causes uninitialized accessible object
When importing Gtk.py from gi.repository in a script which does not call GTK main loop (Gtk.main()) the script generates uninitialized accessible object.
I have written the following small scripts to debug the issue:
- dump_accessible.py: waits 2 seconds (the starting of app_starter.py), gets desktop from pyatspi registry and iterates through the open GTK applications. There is a timer at the end to see execution time of the listing of applications.
- app_starter.py: starts gtk3-demo application, waits 20 seconds, and exits. With from gi.repository import Gtk bug appears.
- dump_test.sh: starts the python scripts above.
Executing dump_test.sh returns the following output:
...
[application | Chromium]
[application | nautilus]
[application | gtk3-demo]
Elapsed time: 0.098
After adding from gi.repository import Gtk to app_starter.py the execution time of dump_accessible.py becomes very high and the uninitialized object appears:
...
[application | Chromium]
[application | nautilus]
[DEAD]
[application | gtk3-demo]
Elapsed time: 15.006
You can see that instead of [application | app_starter.py] I get a [DEAD] object. If I add Gtk.main() to app_starter.py then I get the right object and the time of listing returns to normal (< 1.000).
Tested it multiple operation systems and versions but the bug still exists:
-
OS version: Ubuntu 18.04
gi version: 3.26.1
GTK version: 3.22.30 -
OS version: Debian 10
gi version 3.30.4
GTK version: 3.24.5
IRL I use a third party library called Dogtail to test graphical application. Dogtail imports Gtk.py from gi therefore I cannot bypass this import but it breaks my tests.