Overzealous registration makes orca unresponsive
Hello,
The attached program test.py make Orca unresponsive for some time when it is run. py-bt shows:
File "/usr/lib/python3/dist-packages/pyatspi/Accessibility.py", line 56, in Accessible_str
return '[%s | %s]' % (self.getRoleName(), self.name)
File "/usr/local/stow/orca/lib/python3.7/site-packages/orca/event_manager.py", line 106, in _ignore
event.detail1,event.detail2, event.any_data)
File "/usr/local/stow/orca/lib/python3.7/site-packages/orca/event_manager.py", line 325, in _enqueue
ignore = isObjectEvent and self._ignore(e)
File "/usr/lib/python3/dist-packages/pyatspi/registry.py", line 209, in eventWrapper
return callback(event)
File "/usr/lib/python3/dist-packages/pyatspi/registry.py", line 174, in start
Atspi.event_main()
File "/usr/local/stow/orca/lib/python3.7/site-packages/orca/orca.py", line 584, in start
registry.start(gil=False)
File "/usr/local/stow/orca/lib/python3.7/site-packages/orca/orca.py", line 752, in main
start(pyatspi.Registry, cacheValues) # waits until we stop the registry
File "/usr/local/bin/orca", line 269, in main
return orca.main()
File "/usr/local/bin/orca", line 272, in <module>
sys.exit(main())
which will eventually print something like
21:15:08 - EVENT MANAGER: object:children-changed:add for [desktop frame | main] in None (4, 0, [DEAD])
i.e. it's stuck on trying to print the any_data, which is the application being registered. On the client side, we have the following thing happening:
#0 0x00007ffff7f38420 in __libc_sendmsg (fd=fd@entry=5, msg=msg@entry=0x7fffffffa210, flags=flags@entry=16384)
at ../sysdeps/unix/sysv/linux/sendmsg.c:28
#1 0x00007ffff3fd0faa in _dbus_write_socket_with_unix_fds_two
(fd=..., buffer1=<optimized out>, start1=<optimized out>, len1=<optimized out>, buffer2=<optimized out>, start2=start2@entry=0, len2=48, fds=0x0, n_fds=0) at ../../../dbus/dbus-sysdeps-unix.c:599
#2 0x00007ffff3fca42d in do_writing (transport=<optimized out>) at ../../../dbus/dbus-transport-socket.c:618
#3 0x00007ffff3fca42d in do_writing (transport=0xbceda0) at ../../../dbus/dbus-transport-socket.c:503
#4 0x00007ffff3fca5ce in socket_do_iteration (transport=0xbceda0, flags=1, timeout_milliseconds=-1) at ../../../dbus/dbus-transport-socket.c:1131
#5 0x00007ffff3fc92dd in _dbus_transport_do_iteration (transport=0xbceda0, flags=<optimized out>, timeout_milliseconds=<optimized out>)
at ../../../dbus/dbus-transport.c:1016
#6 0x00007ffff3fb16dc in _dbus_connection_do_iteration_unlocked
(connection=connection@entry=0xbce780, pending=pending@entry=0x0, flags=flags@entry=1, timeout_milliseconds=timeout_milliseconds@entry=-1)
at ../../../dbus/dbus-connection.c:1227
#7 0x00007ffff3fb17c7 in _dbus_connection_send_preallocated_unlocked_no_update
(connection=connection@entry=0xbce780, preallocated=0x0, message=message@entry=0xbcd090, client_serial=client_serial@entry=0x0)
at ../../../dbus/dbus-connection.c:2057
#8 0x00007ffff3fb1848 in _dbus_connection_send_unlocked_no_update
(connection=connection@entry=0xbce780, message=message@entry=0xbcd090, client_serial=0x0) at ../../../dbus/dbus-connection.c:3268
#9 0x00007ffff3fb251d in dbus_connection_send_with_reply
(timeout_milliseconds=-1, pending_return=0x7fffffffa4a8, message=0xbcd090, connection=0xbce780) at ../../../dbus/dbus-connection.c:3469
#10 0x00007ffff3fb251d in dbus_connection_send_with_reply
(connection=0xbce780, message=message@entry=0xbcd090, pending_return=pending_return@entry=0x7fffffffa4a8, timeout_milliseconds=timeout_milliseconds@entry=-1) at ../../../dbus/dbus-connection.c:3400
#11 0x00007ffff3ffd583 in register_application (app=0xbcc9b0) at ../atk-adaptor/bridge.c:429
#12 0x00007ffff3ffe2a3 in atk_bridge_adaptor_init (argc=argc@entry=0x0, argv=argv@entry=0x0) at ../atk-adaptor/bridge.c:1103
#13 0x00007ffff44d66a4 in _gtk_accessibility_init () at ../../../../gtk/a11y/gtkaccessibility.c:992
#14 0x00007ffff46828a6 in default_display_notify_cb (dm=0x9d04c0 [GdkDisplayManager]) at ../../../../gtk/gtkmain.c:765
#15 0x00007ffff46828a6 in do_post_parse_initialization (argc=0x0, argv=0x0) at ../../../../gtk/gtkmain.c:765
#16 0x00007ffff46828a6 in post_parse_hook (context=<optimized out>, group=<optimized out>, data=0x8ccbc0, error=0x7fffffffa680)
at ../../../../gtk/gtkmain.c:798
#17 0x00007ffff718b747 in g_option_context_parse
(context=context@entry=0x8ccb60, argc=argc@entry=0xacdd40, argv=argv@entry=0xacdd60, error=error@entry=0x7fffffffa680)
at ../../../glib/goption.c:2175
#18 0x00007ffff4682628 in gtk_parse_args (argc=0xacdd40, argv=0xacdd60) at ../../../../gtk/gtkmain.c:1058
#19 0x00007ffff4682696 in gtk_init_check (argc=<optimized out>, argv=<optimized out>) at ../../../../gtk/gtkmain.c:1101
which is coming from
Traceback (most recent call first):
File "/usr/lib/python3/dist-packages/gi/overrides/Gtk.py", line 1651, in <module>
initialized, argv = Gtk.init_check(sys.argv)
<built-in method exec of module object at remote 0x7ffff7fbfd10>
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib/python3/dist-packages/gi/overrides/__init__.py", line 125, in load_overrides
override_mod = importlib.import_module(override_package_name)
File "/usr/lib/python3/dist-packages/gi/importer.py", line 146, in load_module
dynamic_module = load_overrides(introspection_module)
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1035, in _handle_fromlist
File "test.py", line 5, in <module>
from gi.repository import Gtk
All in all, what is happening is that just because it imports gtk, the test script ends up registering itself to at-spi. But since it does not actually run the glib main loop, it will not answer to any at-spi requests, and thus Orca keeps waiting until timing out.
I'm not sure how we should fix this:
- the application could be made to avoid importing gtk when not using it, but we can't fight the whole FOSS crowd :)
- we could change the atk bridge to plug itself later, when it is really determined somehow that there is some GUI to expose in at-spi.
- Orca could be made to avoid printing any_data in this particular case: until it receives real events from an application, it could be that we are in such a case where orca will never get answers.
Thus pinging @joanmarie as well.