Gtk 桌面应用程序首次启动时延迟(20.04)

Gtk 桌面应用程序首次启动时延迟(20.04)

我有一个需要 root 权限的 Gtkmm 桌面应用。它在 18.04 上运行良好,使用须藤但升级到 20.0.4 后,需要大约 30 秒才能打开仅有的启动后第一次启动时会显示此错误。此外,它会跳过应该显示 3 秒的启动画面。但是,每次后续启动都会显示启动画面,并且一切正常,直到系统再次重新启动。发生这种情况时的日志:

Mar 15 11:38:07 ubuntu-VirtualBox systemd[1053]: Started Application launched by gnome-shell.
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] AppArmor D-Bus mediation is enabled
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.portal.Desktop' requested by ':1.0' (uid=0 pid=3140 comm="/usr/bin/configuration-tool " label="unconfined")
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.portal.Documents' requested by ':1.1' (uid=0 pid=3155 comm="/usr/libexec/xdg-desktop-portal " label="unconfined")
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.impl.portal.PermissionStore' requested by ':1.2' (uid=0 pid=3160 comm="/usr/libexec/xdg-document-portal " label="unconfined")
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.impl.portal.PermissionStore'
Mar 15 11:38:09 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.portal.Documents'
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.impl.portal.desktop.gtk' requested by ':1.1' (uid=0 pid=3155 comm="/usr/libexec/xdg-desktop-portal " label="unconfined")
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.gtk.vfs.Daemon' requested by ':1.4' (uid=0 pid=3174 comm="/usr/libexec/xdg-desktop-portal-gtk " label="unconfined")
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.gtk.vfs.Daemon'
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='ca.desrt.dconf' requested by ':1.4' (uid=0 pid=3174 comm="/usr/libexec/xdg-desktop-portal-gtk " label="unconfined")
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.impl.portal.desktop.gtk'
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.FileManager1' requested by ':1.1' (uid=0 pid=3155 comm="/usr/libexec/xdg-desktop-portal " label="unconfined")
Mar 15 11:38:10 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'ca.desrt.dconf'
Mar 15 11:38:35 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Activating service name='org.freedesktop.secrets' requested by ':1.1' (uid=0 pid=3155 comm="/usr/libexec/xdg-desktop-portal " label="unconfined")
Mar 15 11:38:35 ubuntu-VirtualBox org.freedesktop.secrets[3218]: GNOME_KEYRING_CONTROL=/root/.cache/keyring-88PV11
Mar 15 11:38:35 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.secrets'
Mar 15 11:38:35 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.portal.Desktop'
Mar 15 11:38:35 ubuntu-VirtualBox dbus-daemon[3152]: [session uid=0 pid=3150] Successfully activated service 'org.freedesktop.FileManager1'
Mar 15 11:38:35 ubuntu-VirtualBox nautilus[3201]: Unable to get contents of the bookmarks file: Error opening file /root/.gtk-bookmarks: No such file or directory
Mar 15 11:39:05 ubuntu-VirtualBox xdg-desktop-por[3155]: Failed to get application states: GDBus.Error:org.freedesktop.portal.Error.Failed: Could not get window list

我尝试过的:
只需修改如下所示的桌面文件(参见“Exec”值)似乎可以解决大多数用户的问题,但没有成功。我现在正在使用执行命令而不是 lqxt-sudo,因为这似乎是推荐的方法。

[Desktop Entry]
Encoding=UTF-8
Version=1.8.3
Name=Configuration Tool
Exec=sh -c "pkexec --disable-internal-agent env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY /usr/bin/configuration-tool"
Icon=/usr/share/icons/configuration-tool/icon_v2.png
Terminal=false
Type=Application
Categories=GNOME;GTK;

我也尝试按照一些帖子的建议构建一个 policykit 操作,但即使我授予该程序完全访问权限,首次启动时仍然会延迟:

<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE policyconfig PUBLIC
  "-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
  "http://www.freedesktop.org/standards/PolicyKit/1/policyconfig.dtd">
 <policyconfig>
   <action id="org.freedesktop.policykit.pkexec.run-configuration-tool">
    <description>Run configuration-tool</description>
    <message>Authentication is required to run configuration-tool</message>
    <defaults>
      <allow_any>yes</allow_any>
      <allow_inactive>yes</allow_inactive>
      <allow_active>yes</allow_active>
    </defaults>
    <annotate key="org.freedesktop.policykit.exec.path">/usr/bin/configuration-tool</annotate>
    <annotate key="org.freedesktop.policykit.exec.allow_gui">TRUE</annotate>
  </action>
 </policyconfig>

答案1

看起来是 xdg-desktop-portal 的问题。其他用户也报告了类似的问题: https://bugs.launchpad.net/ubuntu/+source/xdg-desktop-portal/+bug/1878081

尝试卸载 xdg-desktop-portal 并查看是否能解决问题:

sudo apt remove xdg-desktop-portal

编辑:或者更好的选择,尝试降级到工作版本。

答案2

我在 NVIDIA OrinNX arm64 平台上使用 Ubuntu 20.04,内核版本为 5.10.120。

最初,我的系统安装了以下软件包:

dpkg -l | grep xdg-desktop-portal
xdg-desktop-portal 1.6.0-1ubuntu2
xdg-desktop-portal-gtk 1.6.0-1ubuntu1

就我而言,我使用以下命令解决了该问题:

sudo apt remove xdg-desktop-portal-gtk

这样命令就不会启动得很慢:

sudo gnome-terminal

相关内容