pinentry: grab_keyboard iteration count, tiling window managers & tooltips

Robin H. Johnson robbat2 at gentoo.org
Sat Feb 18 05:43:19 CET 2017


TL;DR: gtk-2 tooltips interfere with gdk_keyboard_grab in some window 
       managers, recommend disabling tooltips.

I recently upgraded from pinentry 0.9.7 to pinentry 1.0.0, using the
gtk+-2 frontend, and was very surprised to have it break on me in a
strange way: the window would appear and disappear. It also still seemed
to be present in master (as of cd7b35e8ff)

I use a tiling WM, Awesome, so I've seen similar glitches in the past
for windows that wanted to steal focus.

Reproducable via:
$ pinentry-gtk-2 <<< "GETPIN" 
** (pinentry-gtk-2:10527): CRITICAL **: could not grab keyboard: not viewable (3)
** (pinentry-gtk-2:10527): WARNING **: it took 4097 tries to grab the keyboard
** (pinentry-gtk-2:10527): WARNING **: it took 233 tries to grab the pointer

The issue did appear to be very similar to the previously reported
Debian bug 850708, which added a fix for FVWM; however, even master
still seemed to be problematic.

With git bisect, I narrowed it down to commit f4b5049c68, which was
strange, because it was adding a new button.

Some further digging within that commit, showed that if I commented out a
single line:
gtk+-2/pinentry-gtk-2.c:519:
  gtk_widget_set_tooltip_text (GTK_WIDGET(button), tooltip);

The issue reliably went away, as well and pinentry did NOT even need to retry
the grab.

Alternatively, if I raised the grab_keyboard max_tries limit past 4096, it DOES
eventually succeed:

$ pinentry-gtk-2 <<< "GETPIN" 2>&1
OK Pleased to meet you
** (pinentry-gtk-2:12534): WARNING **: it took 4705 tries to grab the keyboard
D testing123
OK
I went digging in Google for Gtk-2 tooltip and grabbing devices, and found that
tooltip and grabbing seem to have longstanding issues together in gtk-2:
https://bugzilla.gnome.org/show_bug.cgi?id=615451

Raising the count is a kind of crappy option in my opinion, so I'd like to
consider the alternative of disabling the tooltip until such time as upstream
Gtk fixes their issue.

If we did want to go with raising the count, an hour of testing (while I went
for dinner) the following on my system showed the highest count was ~7500 tries
to grab the keyboard, so I'm not sure that 8192 tries will cover all cases
reliably.

(login from another system and touch 'escape' to kill the loop)
# while true ; do \
  [ -e escape ] && break ; \
  timeout 1 ./gtk+-2/pinentry-gtk-2 <<< "GETPIN" 2>&1 ; \
  sleep 0.1 ; \
  done | tee logfile

-- 
Robin Hugh Johnson
Gentoo Linux: Dev, Infra Lead, Foundation Trustee & Treasurer
E-Mail   : robbat2 at gentoo.org
GnuPG FP : 11ACBA4F 4778E3F6 E4EDF38E B27B944E 34884E85
GnuPG FP : 7D0B3CEB E9B85B1F 825BCECF EE05E6F6 A48F6136
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1083 bytes
Desc: Digital signature
URL: </pipermail/attachments/20170218/8fe88fef/attachment.sig>


More information about the Gnupg-devel mailing list