Package: debconf
Version: 1.5.86ubuntu1
Severity: normal
Tags: patch
File: /usr/share/perl5/Debconf/FrontEnd/Gnome.pm

When an interactive debconf question is asked during a package transaction
started from a graphical installer (mintupdate/aptkit, PackageKit, GNOME
Software), the debconf GNOME assistant window is mapped but never raised or
focused. If the user has any window stacked above it, the installer appears to
hang at "Applying changes" with no clue that a question is waiting.

Real case, this reporting machine: a gdm3 question ("Default display
manager:") was queued by dpkg-preconfigure during a mintupdate transaction and
rendered underneath the update window. It sat unanswered for 20 hours. Nothing
had been unpacked yet, the progress bar never moved, and there was no way to
tell from the GUI that a dialog was waiting.

Root cause
----------
Debconf/FrontEnd/Gnome.pm creates an ordinary toplevel with no stacking or
attention hints:

  $this->assistant(Gtk3::Assistant->new);
  $this->assistant->set_position("center");
  ...
  $this->assistant->show;

There is no gtk_window_set_keep_above, no gtk_window_present /
present_with_time, and no gtk_window_set_urgency_hint. The frontend is spawned
by pk-debconf-helper, which is socket activated as a systemd --user unit, so
it has no transient-for parent and emits no startup notification that the
window manager could use to place it. Under focus-stealing prevention
(Muffin/Cinnamon, Mutter/GNOME, Xfwm, KWin) the window is therefore mapped
beneath whatever is currently on top and without focus.

Proposed fix
------------
Set keep_above and the urgency hint when the assistant is created, re-assert
keep_above and present the window each time an interactive question is about
to be shown, and drop keep_above when a non-interactive progress page is
displayed so the assistant does not float above everything for the whole
transaction.

Tested on Linux Mint 22.3 (Cinnamon 6 / Muffin, X11), debconf 1.5.86ubuntu1,
libgtk3-perl 0.038. With the patch applied, running

  sudo debconf --frontend=gnome ... (via dpkg-reconfigure -f gnome debconf)

produces a window whose _NET_WM_STATE is

  _NET_WM_STATE_ABOVE, _NET_WM_STATE_FOCUSED

Without the patch the same window carries neither hint and can be mapped
behind the caller. All of set_keep_above, set_urgency_hint, present,
present_with_time and get_window exist in libgtk3-perl 0.038 and apply without
error.

Patch (against debconf 1.5.86ubuntu1, 
/usr/share/perl5/Debconf/FrontEnd/Gnome.pm):

--- a/Debconf/FrontEnd/Gnome.pm
+++ b/Debconf/FrontEnd/Gnome.pm
@@ -174,6 +174,12 @@
 
        $this->assistant(Gtk3::Assistant->new);
        $this->assistant->set_position("center");
+       # Stay above the installer that spawned us: the frontend runs from a
+       # socket-activated unit with no transient parent, so under 
focus-stealing
+       # prevention the window otherwise maps underneath the caller's window 
and
+       # the transaction silently waits for an answer nobody can see.
+       $this->assistant->set_keep_above(1);
+       $this->assistant->set_urgency_hint(1);
        $this->assistant->set_default_size(600, 400);
        my $hostname = `hostname`;
        chomp $hostname;
@@ -213,6 +219,7 @@
        $this->create_assistant_page();
 
        $this->assistant->show;
+       $this->assistant->present;
 }
 
 
@@ -235,6 +242,8 @@
                if ($this->assistant->get_current_page == 
$this->assistant->get_n_pages - 1) {
                        $this->create_assistant_page();
                }
+               $this->assistant->set_keep_above(1);
+               $this->assistant->present;
                Gtk3::main();
        }
 
@@ -250,6 +259,9 @@
        my $this=shift;
        $this->SUPER::progress_start(@_);
 
+       # progress pages are not questions: stop floating above everything
+       $this->assistant->set_keep_above(0);
+
        $this->reset_assistant_page;
 
        my $element=$this->progress_bar;

Related, not duplicates
-----------------------
- PackageKit issues #452 and #989 (pk-debconf-helper at 100% CPU, update hangs)
  and linuxmint/mintupdate#1052 describe the same user-visible symptom, a hung
  progress bar, through a different mechanism. This report is only about the
  window not being raised or focused.
- Ubuntu LP #2086773 was the Wayland variant where the GTK helper window did
  not appear at all (fixed in packagekit 1.3.0-2).

I could not find an existing report for this in the debconf BTS; the upstream
salsa issue tracker is disabled, hence this mail.

Regards,
Christian Sass
Binary Ranch

Reply via email to