flatpak / xdg-desktop-portal-gtk

Gtk implementation of xdg-desktop-portal
GNU Lesser General Public License v2.1
125 stars 98 forks source link

Failed to start Portal service #107

Closed 183amir closed 3 years ago

183amir commented 6 years ago

Similar to #72 when I run a dbus-activated app (installed using flatpak) it takes forever to start. Looking at the logs I see that the portal fails to load:

Dec 26 16:15:09 VirtualBox dbus-daemon[994]: Activating via systemd: service name='org.freedesktop.portal.Documents' unit='xdg-document-portal.service'
Dec 26 16:15:09 VirtualBox systemd[971]: Starting flatpak document portal service...
Dec 26 16:15:09 VirtualBox systemd[1]: Starting Message of the Day...
Dec 26 16:15:09 VirtualBox dbus-daemon[994]: Successfully activated service 'org.freedesktop.portal.Documents'
Dec 26 16:15:09 VirtualBox systemd[971]: Started flatpak document portal service.
Dec 26 16:15:09 VirtualBox systemd[1]: Started Message of the Day.
Dec 26 16:15:10 VirtualBox dbus-daemon[994]: Activating via systemd: service name='org.freedesktop.Flatpak' unit='flatpak-session-helper.service'
Dec 26 16:15:10 VirtualBox systemd[971]: Starting flatpak session helper...
Dec 26 16:15:10 VirtualBox dbus-daemon[994]: Successfully activated service 'org.freedesktop.Flatpak'
Dec 26 16:15:10 VirtualBox systemd[971]: Started flatpak session helper.
Dec 26 16:15:10 VirtualBox pkexec[1904]: pam_unix(polkit-1:session): session opened for user root by (uid=1000)
Dec 26 16:15:10 VirtualBox pkexec[1904]: amir: Executing command [USER=root] [TTY=unknown] [CWD=/home/amir] [COMMAND=/usr/lib/update-notifier/package-system-locked]
Dec 26 16:15:11 VirtualBox dbus-daemon[994]: Activating via systemd: service name='org.freedesktop.portal.Desktop' unit='xdg-desktop-portal.service'
Dec 26 16:15:11 VirtualBox systemd[971]: Starting Portal service...
Dec 26 16:15:11 VirtualBox dbus-daemon[994]: Activating via systemd: service name='org.freedesktop.impl.portal.desktop.gtk' unit='xdg-desktop-portal-gtk.service'
Dec 26 16:15:11 VirtualBox systemd[971]: Starting Portal service (GTK+/GNOME implementation)...
Dec 26 16:15:36 VirtualBox xdg-desktop-por[1915]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gtk: Timeout was reached
Dec 26 16:15:36 VirtualBox xdg-desktop-por[1915]: g_dbus_interface_skeleton_set_flags: assertion 'G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed
Dec 26 16:15:36 VirtualBox kernel: show_signal_msg: 13 callbacks suppressed
Dec 26 16:15:36 VirtualBox kernel: xdg-desktop-por[1915]: segfault at 8 ip 0000561e07a7c508 sp 00007ffee8cb7260 error 4 in xdg-desktop-portal[561e07a6f000+5b000]
Dec 26 16:15:36 VirtualBox xdg-desktop-por[1915]: invalid (NULL) pointer instance
Dec 26 16:15:36 VirtualBox xdg-desktop-por[1915]: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
Dec 26 16:15:36 VirtualBox xdg-desktop-por[1915]: g_dbus_interface_skeleton_export: assertion 'G_IS_DBUS_INTERFACE_SKELETON (interface_)' failed
Dec 26 16:15:37 VirtualBox systemd[971]: xdg-desktop-portal.service: Main process exited, code=dumped, status=11/SEGV
Dec 26 16:15:37 VirtualBox systemd[971]: Failed to start Portal service.
Dec 26 16:15:37 VirtualBox systemd[971]: xdg-desktop-portal.service: Unit entered failed state.
Dec 26 16:15:37 VirtualBox systemd[971]: xdg-desktop-portal.service: Failed with result 'core-dump'.
Dec 26 16:15:47 VirtualBox dbus-daemon[994]: Successfully activated service 'org.freedesktop.impl.portal.desktop.gtk'
Dec 26 16:15:47 VirtualBox systemd[971]: Started Portal service (GTK+/GNOME implementation).

the workaround mentioned in #72 solves the slownees issue too. This issue happens in a Gnome environment in both Arch Linux and a fresh install of Ubuntu 17.10.

The question is why my session is not setting this environment up for me? I am not using i3wm or anything. I am using vanilla Gnome 3.

Also, why does this happen only with portal? Any other non-flatpak that I launch using dbus starts instantly.

matthiasclasen commented 6 years ago

if you run /usr/libexec/xdg-desktop-portal on the commandline, does it start normally ? it would be good to get a stacktrace from that segfault

183amir commented 5 years ago

Sorry for not getting back to you earlier. I lost the means to reproduce this for a while. This issue still exists in Gnome 3.30 Arch Linux

Here is the stack trace:

Stack trace of thread 3240:
#0  0x000055bfb3a3aac8 n/a (xdg-desktop-portal)
#1  0x000055bfb3a3ab68 n/a (xdg-desktop-portal)
#2  0x00007fa252408687 n/a (libgio-2.0.so.0)
#3  0x00007fa2524590f4 n/a (libgio-2.0.so.0)
#4  0x00007fa25245bad7 n/a (libgio-2.0.so.0)
#5  0x00007fa252406543 n/a (libgio-2.0.so.0)
#6  0x00007fa2524590f4 n/a (libgio-2.0.so.0)
#7  0x00007fa252459129 n/a (libgio-2.0.so.0)
#8  0x00007fa25228f271 g_main_context_dispatch (libglib-2.0.so.0)
#9  0x00007fa252290f89 n/a (libglib-2.0.so.0)
#10 0x00007fa252291f62 g_main_loop_run (libglib-2.0.so.0)
#11 0x000055bfb3a3a4ed n/a (xdg-desktop-portal)
#12 0x00007fa25202a223 __libc_start_main (libc.so.6)
#13 0x000055bfb3a3a70e n/a (xdg-desktop-portal)

Stack trace of thread 3241:
#0  0x00007fa2520f6c21 __poll (libc.so.6)
#1  0x00007fa252290ee0 n/a (libglib-2.0.so.0)
#2  0x00007fa252290fce g_main_context_iteration (libglib-2.0.so.0)
#3  0x00007fa252291022 n/a (libglib-2.0.so.0)
#4  0x00007fa25225a3eb n/a (libglib-2.0.so.0)
#5  0x00007fa2521d1a9d start_thread (libpthread.so.0)
#6  0x00007fa252101b23 __clone (libc.so.6)

Stack trace of thread 3244:
#0  0x00007fa2520f6c21 __poll (libc.so.6)
#1  0x00007fa252290ee0 n/a (libglib-2.0.so.0)
#2  0x00007fa252290fce g_main_context_iteration (libglib-2.0.so.0)
#3  0x00007fa25018bbde n/a (libdconfsettings.so)
#4  0x00007fa25225a3eb n/a (libglib-2.0.so.0)
#5  0x00007fa2521d1a9d start_thread (libpthread.so.0)
#6  0x00007fa252101b23 __clone (libc.so.6)

Stack trace of thread 3242:
#0  0x00007fa2520f6c21 __poll (libc.so.6)
#1  0x00007fa252290ee0 n/a (libglib-2.0.so.0)
#2  0x00007fa252291f62 g_main_loop_run (libglib-2.0.so.0)
#3  0x00007fa2523f6c28 n/a (libgio-2.0.so.0)
#4  0x00007fa25225a3eb n/a (libglib-2.0.so.0)
#5  0x00007fa2521d1a9d start_thread (libpthread.so.0)
#6  0x00007fa252101b23 __clone (libc.so.6)

and when I run /usr/lib/xdg-desktop-portal from the terminal, it just hangs it does not exit and runs. Is it hanging or is it supposed to just run with no output? I don't know.

To reproduce this, you can install this app: https://flathub.org/apps/details/org.gahshomar.Gahshomar and then run it right after you have logged in.

Please let me know if you want more information.

183amir commented 5 years ago

Could you please reopen this issue?

183amir commented 5 years ago

Gentle reminder @matthiasclasen once an issue is closed, only the maintainers can re-open it.

183amir commented 5 years ago

Running dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY does not fix this issue anymore. It used to work before but not with latest Gnome anymore.

Sorry about that. It seems to work.

mcatanzaro commented 5 years ago

@183amir can you please follow the instructions at https://wiki.gnome.org/Community/GettingInTouch/Bugzilla/GettingTraces to install debuginfo, so we can get a useful backtrace for the crash? The trace you posted is not useful because it does not contain debuginfo for any of the libraries in the crash. We probably only need one thread for this, but it should be a full trace showing member variables, so please take the trace using bt full rather than thread apply all bt.

183amir commented 5 years ago

To get the debug info in archlinux, I have to rebuild the package but I am facing an error in compiling the package:

$ makepkg -siCf
==> Making package: xdg-desktop-portal 1.0.3-1 (Wed 16 Jan 2019 05:49:15 AM CET)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Updating xdg-desktop-portal git repo...
Fetching origin
==> Validating source files with sha256sums...
    xdg-desktop-portal ... Skipped
==> Removing existing $srcdir/ directory...
==> Extracting sources...
  -> Creating working copy of xdg-desktop-portal git repo...
Cloning into 'xdg-desktop-portal'...
done.
Note: checking out '4d19f0e403f68382866ebd60bd1b9ea7b9fcf52f'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

Switched to a new branch 'makepkg'
==> Starting prepare()...
autoreconf: Entering directory `.'
autoreconf: running: autopoint --force
Copying file ABOUT-NLS
Copying file config.rpath
Copying file m4/codeset.m4
Copying file m4/extern-inline.m4
Copying file m4/fcntl-o.m4
Copying file m4/gettext.m4
Copying file m4/glibc2.m4
Copying file m4/glibc21.m4
Copying file m4/iconv.m4
Copying file m4/intdiv0.m4
Copying file m4/intl.m4
Copying file m4/intldir.m4
Copying file m4/intlmacosx.m4
Copying file m4/intmax.m4
Copying file m4/inttypes-pri.m4
Copying file m4/inttypes_h.m4
Copying file m4/lcmessage.m4
Copying file m4/lib-ld.m4
Copying file m4/lib-link.m4
Copying file m4/lib-prefix.m4
Copying file m4/lock.m4
Copying file m4/longlong.m4
Copying file m4/nls.m4
Copying file m4/po.m4
Copying file m4/printf-posix.m4
Copying file m4/progtest.m4
Copying file m4/size_max.m4
Copying file m4/stdint_h.m4
Copying file m4/threadlib.m4
Copying file m4/uintmax_t.m4
Copying file m4/visibility.m4
Copying file m4/wchar_t.m4
Copying file m4/wint_t.m4
Copying file m4/xsize.m4
Copying file po/Makefile.in.in
Copying file po/Makevars.template
Copying file po/Rules-quot
Copying file po/boldquot.sed
Copying file po/en@boldquot.header
Copying file po/en@quot.header
Copying file po/insert-header.sin
Copying file po/quot.sed
Copying file po/remove-potcdate.sin
autoreconf: running: aclocal --force --install -I m4 ${ACLOCAL_FLAGS}
aclocal: installing 'm4/libtool.m4' from '/usr/share/aclocal/libtool.m4'
aclocal: installing 'm4/ltoptions.m4' from '/usr/share/aclocal/ltoptions.m4'
aclocal: installing 'm4/ltsugar.m4' from '/usr/share/aclocal/ltsugar.m4'
aclocal: installing 'm4/ltversion.m4' from '/usr/share/aclocal/ltversion.m4'
aclocal: installing 'm4/lt~obsolete.m4' from '/usr/share/aclocal/lt~obsolete.m4'
aclocal: installing 'm4/pkg.m4' from '/usr/share/aclocal/pkg.m4'
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy --force
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: putting macros in AC_CONFIG_MACRO_DIRS, 'm4'.
libtoolize: copying file 'm4/libtool.m4'
libtoolize: copying file 'm4/ltoptions.m4'
libtoolize: copying file 'm4/ltsugar.m4'
libtoolize: copying file 'm4/ltversion.m4'
libtoolize: copying file 'm4/lt~obsolete.m4'
autoreconf: running: /usr/bin/autoconf --force
autoreconf: running: /usr/bin/autoheader --force
autoreconf: running: automake --add-missing --copy --force-missing
configure.ac:5: installing './compile'
configure.ac:13: installing './config.guess'
configure.ac:13: installing './config.sub'
configure.ac:18: installing './install-sh'
configure.ac:18: installing './missing'
Makefile.am: installing './depcomp'
parallel-tests: installing './test-driver'
autoreconf: Leaving directory `.'
==> Starting pkgver()...
==> Removing existing $pkgdir/ directory...
==> Starting build()...
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking minix/config.h usability... no
checking minix/config.h presence... no
checking for minix/config.h... no
checking whether it is safe to define __EXTENSIONS__... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking for gawk... gawk
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking whether make sets $(MAKE)... yes
checking whether make supports the include directive... yes (GNU style)
checking whether make supports nested variables... yes
checking whether UID '1000' is supported by ustar format... yes
checking whether GID '1000' is supported by ustar format... yes
checking how to create a ustar tar archive... gnutar
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... (cached) /usr/bin/sed
checking whether make supports nested variables... (cached) yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether NLS is requested... yes
checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
checking for msgmerge... /usr/bin/msgmerge
checking for ld used by gcc... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking for shared library run path origin... done
checking for CFPreferencesCopyAppValue... no
checking for CFLocaleCopyCurrent... no
checking for GNU gettext in libc... yes
checking whether to use NLS... yes
checking where the gettext function comes from... libc
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.24... yes
checking for BASE... yes
checking for PIPEWIRE... yes
checking for xmlto... /usr/bin/xmlto
checking whether to build DocBook documentation... yes
checking for FUSE... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating xdg-desktop-portal.pc
config.status: creating doc/Makefile
config.status: creating doc/portal-docs.xml
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing libtool commands
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
Makefile:3361: warning: overriding recipe for target 'lcov-clean'
Makefile:3274: warning: ignoring old recipe for target 'lcov-clean'
Makefile:3364: warning: overriding recipe for target 'genlcov'
Makefile:3269: warning: ignoring old recipe for target 'genlcov'
mkdir -p ./document-portal
  GEN      document-portal/permission-store-dbus.c
mkdir -p ./document-portal
  GEN      document-portal/document-portal-dbus.c
  GEN      src/xdp-dbus.c
  GEN      src/xdp-impl-dbus.c
make  all-recursive
make[1]: Entering directory '/archlinux/xdg-desktop-portal/src/xdg-desktop-portal'
Makefile:3361: warning: overriding recipe for target 'lcov-clean'
Makefile:3274: warning: ignoring old recipe for target 'lcov-clean'
Makefile:3364: warning: overriding recipe for target 'genlcov'
Makefile:3269: warning: ignoring old recipe for target 'genlcov'
Making all in doc
make[2]: Entering directory '/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc'
cp /usr/share/dbus-1/interfaces/org.freedesktop.portal.Flatpak.xml .
  GEN      portal-org.freedesktop.portal.Flatpak.xml
  GEN      portal-docs.html
xmlto: /archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml does not validate (status 3)
xmlto: Fix document syntax or use --skip-validation option
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:119: parser error : Opening and ending tag mismatch: varlistentry line 109 and para
             </para></listitem>
                    ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:119: parser error : Opening and ending tag mismatch: variablelist line 97 and listitem
             </para></listitem>
                               ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:120: parser error : Opening and ending tag mismatch: para line 96 and varlistentry
           </varlistentry>
                          ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:121: parser error : Opening and ending tag mismatch: refsect2 line 49 and variablelist
         </variablelist>
                        ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:122: parser error : Opening and ending tag mismatch: refsect1 line 47 and para
</para>
       ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:153: parser error : Opening and ending tag mismatch: refentry line 5 and refsect2
</refsect2>
           ^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml:154: parser error : Extra content at the end of the document
<refsect2 role="method" id="gdbus-method-org-freedesktop-portal-Flatpak.SpawnSig
^
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml:109: element include: XInclude error : could not load /archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-org.freedesktop.portal.Flatpak.xml, and no fallback was found
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml:82: element reference: validity error : Element reference content does not follow the DTD, expecting (beginpage? , referenceinfo? , (title , subtitle? , titleabbrev?) , partintro? , refentry+), got (title partintro refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry refentry xi:include )
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml:109: element include: validity error : No declaration for element include
/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml:109: element include: validity error : No declaration for attribute href of element include
Document /archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc/portal-docs.xml does not validate
make[2]: *** [Makefile:632: portal-docs.html] Error 13
make[2]: Leaving directory '/archlinux/xdg-desktop-portal/src/xdg-desktop-portal/doc'
make[1]: *** [Makefile:2509: all-recursive] Error 1
make[1]: Leaving directory '/archlinux/xdg-desktop-portal/src/xdg-desktop-portal'
make: *** [Makefile:1110: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
makepkg -siCf  17.34s user 2.01s system 92% cpu 20.967 total

Do you have any idea what could be the problem? I am using this PKGBUILD file to compile xdg-desktop-portal: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/xdg-desktop-portal

matthiasclasen commented 5 years ago

I just fixed this problem (invalid xml) here: https://github.com/flatpak/flatpak/commit/f28e8af9680074e1a6b4e6c90cb337fe2d52f26e

183amir commented 5 years ago

Here is the stacktrace with xdg-desktop-portal symbols:

Process 24487 (xdg-desktop-por) of user 1000 dumped core.

Stack trace of thread 24487:
#0  0x00005572dc760ac8 export_portal_implementation (xdg-desktop-portal)
#1  0x00005572dc760b68 on_bus_acquired (xdg-desktop-portal)
#2  0x00007fc60440c7d7 n/a (libgio-2.0.so.0)
#3  0x00007fc60445d2f4 n/a (libgio-2.0.so.0)
#4  0x00007fc60445fcd7 n/a (libgio-2.0.so.0)
#5  0x00007fc60440a693 n/a (libgio-2.0.so.0)
#6  0x00007fc60445d2f4 n/a (libgio-2.0.so.0)
#7  0x00007fc60445d329 n/a (libgio-2.0.so.0)
#8  0x00007fc6042928d1 g_main_context_dispatch (libglib-2.0.so.0)
#9  0x00007fc6042945e9 n/a (libglib-2.0.so.0)
#10 0x00007fc6042955c2 g_main_loop_run (libglib-2.0.so.0)
#11 0x00005572dc7604ed main (xdg-desktop-portal)
#12 0x00007fc60402d223 __libc_start_main (libc.so.6)
#13 0x00005572dc76070e _start (xdg-desktop-portal)

Stack trace of thread 24489:
#0  0x00007fc6042423b9 g_mutex_lock (libglib-2.0.so.0)
#1  0x00007fc60440071e n/a (libgio-2.0.so.0)
#2  0x00007fc60445d2f4 n/a (libgio-2.0.so.0)
#3  0x00007fc60445d329 n/a (libgio-2.0.so.0)
#4  0x00007fc6042928d1 g_main_context_dispatch (libglib-2.0.so.0)
#5  0x00007fc6042945e9 n/a (libglib-2.0.so.0)
#6  0x00007fc6042955c2 g_main_loop_run (libglib-2.0.so.0)
#7  0x00007fc6043facb8 n/a (libgio-2.0.so.0)
#8  0x00007fc60426f67b n/a (libglib-2.0.so.0)
#9  0x00007fc6041d4a9d start_thread (libpthread.so.0)
#10 0x00007fc604104b23 __clone (libc.so.6)

Stack trace of thread 24488:
#0  0x00007fc6040f9c21 __poll (libc.so.6)
#1  0x00007fc604294540 n/a (libglib-2.0.so.0)
#2  0x00007fc60429462e g_main_context_iteration (libglib-2.0.so.0)
#3  0x00007fc604294682 n/a (libglib-2.0.so.0)
#4  0x00007fc60426f67b n/a (libglib-2.0.so.0)
#5  0x00007fc6041d4a9d start_thread (libpthread.so.0)
#6  0x00007fc604104b23 __clone (libc.so.6)

Stack trace of thread 24491:
#0  0x00007fc6040f9c21 __poll (libc.so.6)
#1  0x00007fc604294540 n/a (libglib-2.0.so.0)
#2  0x00007fc60429462e g_main_context_iteration (libglib-2.0.so.0)
#3  0x00007fc602126bde n/a (libdconfsettings.so)
#4  0x00007fc60426f67b n/a (libglib-2.0.so.0)
#5  0x00007fc6041d4a9d start_thread (libpthread.so.0)
#6  0x00007fc604104b23 __clone (libc.so.6)
183amir commented 5 years ago

Installing flatpak from this commit https://github.com/flatpak/flatpak/commit/f28e8af9680074e1a6b4e6c90cb337fe2d52f26e and installing xdg-desktop-portal 1.1.1 does not result in any segmentation faults anymore. However running Gahshomar for the first time after login does hang the desktop until the desktop portal service is activated. From my experience nothing changed, the desktop still hangs for 15 seconds or so when I run the app. Now it happens the first time only.

183amir commented 5 years ago

It takes around 25 seconds to activate org.freedesktop.impl.portal.desktop.gtk:

Jan 16 07:12:37 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Activating via systemd: service name='org.freedesktop.portal.Documents' unit='xdg-document-portal.service' requested by ':1.12' (uid=1000 pid=13445 comm="/usr/bin/gnome-shell ")
Jan 16 07:12:37 archie systemd[875]: Starting flatpak document portal service...
-- Subject: A start job for unit UNIT has begun execution
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has begun execution.
-- 
-- The job identifier is 1767.
Jan 16 07:12:37 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Successfully activated service 'org.freedesktop.portal.Documents'
Jan 16 07:12:37 archie systemd[875]: Started flatpak document portal service.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1767.
Jan 16 07:12:37 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Activating service name='org.gahshomar.Gahshomar' requested by ':1.12' (uid=1000 pid=13445 comm="/usr/bin/gnome-shell ")
Jan 16 07:12:37 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Activating via systemd: service name='org.freedesktop.Flatpak' unit='flatpak-session-helper.service' requested by ':1.65' (uid=1000 pid=14015 comm="/usr/bin/flatpak run --branch=stable --arch=x86_64")
Jan 16 07:12:37 archie systemd[875]: Starting flatpak session helper...
-- Subject: A start job for unit UNIT has begun execution
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has begun execution.
-- 
-- The job identifier is 1783.
Jan 16 07:12:37 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Successfully activated service 'org.freedesktop.Flatpak'
Jan 16 07:12:37 archie systemd[875]: Started flatpak session helper.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1783.
Jan 16 07:12:37 archie systemd[875]: Started flatpak-org.gahshomar.Gahshomar-14015.scope.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1799.
Jan 16 07:12:38 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Successfully activated service 'org.gahshomar.Gahshomar'
Jan 16 07:12:38 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Activating via systemd: service name='org.freedesktop.portal.Desktop' unit='xdg-desktop-portal.service' requested by ':1.67' (uid=1000 pid=14026 comm="xdg-dbus-proxy --args=33 ")
Jan 16 07:12:38 archie systemd[875]: Starting Portal service...
-- Subject: A start job for unit UNIT has begun execution
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has begun execution.
-- 
-- The job identifier is 1802.
Jan 16 07:12:38 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Activating via systemd: service name='org.freedesktop.impl.portal.desktop.gtk' unit='xdg-desktop-portal-gtk.service' requested by ':1.68' (uid=1000 pid=14037 comm="/usr/lib/xdg-desktop-portal ")
Jan 16 07:12:38 archie systemd[875]: Starting Portal service (GTK+/GNOME implementation)...
-- Subject: A start job for unit UNIT has begun execution
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has begun execution.
-- 
-- The job identifier is 1818.
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.applet@2019-01-16 07:13:03,235 -- DEBUG: AppIndicator enabled: False
Jan 16 07:13:03 archie xdg-desktop-por[14037]: Failed to create file chooser proxy: Error calling StartServiceByName for org.freedesktop.impl.portal.desktop.gtk: Timeout was reached
Jan 16 07:13:03 archie xdg-desktop-por[14037]: No skeleton to export
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.applet@2019-01-16 07:13:03,311 -- DEBUG: StatusIcon enabled: False
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.widgets@2019-01-16 07:13:03,315 -- DEBUG: DayWidget is updating ()
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.widgets@2019-01-16 07:13:03,316 -- DEBUG: DayWidget is updating ()
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.calendar@2019-01-16 07:13:03,323 -- DEBUG: afghan_month accessed False
Jan 16 07:13:03 archie org.gahshomar.Gahshomar[13185]: gahshomar.calendar@2019-01-16 07:13:03,398 -- DEBUG: afghan_month accessed False
Jan 16 07:13:03 archie gnome-shell[13445]: JS WARNING: [/home/amir/.local/share/gnome-shell/extensions/gahshomar@org.gahshomar.Gahshomar/extension.js 110]: assignment to undeclared variable text
Jan 16 07:13:03 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Successfully activated service 'org.freedesktop.impl.portal.desktop.gtk'
Jan 16 07:13:03 archie systemd[875]: Started Portal service (GTK+/GNOME implementation).
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1818.
Jan 16 07:13:03 archie dbus-daemon[13185]: [session uid=1000 pid=13185] Successfully activated service 'org.freedesktop.portal.Desktop'
Jan 16 07:13:03 archie systemd[875]: Started Portal service.
-- Subject: A start job for unit UNIT has finished successfully
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- A start job for unit UNIT has finished successfully.
-- 
-- The job identifier is 1802.

and it hangs the desktop in that time.

183amir commented 5 years ago

Is there any way that I can avoid activating xdg-desktop-portal when running Gahshomar? Here is the flatpak builder definition of Gahshomar: https://github.com/flathub/org.gahshomar.Gahshomar/blob/master/org.gahshomar.Gahshomar.json Gahshomar is a very simple app. It does not need any permission to run except for dconf to save its settings. It doesn't need internet access neither.

183amir commented 5 years ago

Hello, Is there any news on this? I am still facing this issue in archlinux.

183amir commented 5 years ago

Running dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY does not fix this issue anymore. If the xdg-desktop-portal process is running my app launches very quickly. If it's not running, my desktop hangs for 20 seconds and then the app launches with xdg-desktop-portal.

Is there any way that I can avoid activating xdg-desktop-portal when running Gahshomar?

matthiasclasen commented 5 years ago

The portal is expected to be running. Its an issue with the session setup that needs to be fixed, not worked around by avoiding the portal.

183amir commented 5 years ago

Who is supposed to activate this service? I tried enabling it with systemd and I got this:

$ systemctl --user enable xdg-desktop-portal
The unit files have no installation config (WantedBy=, RequiredBy=, Also=,
Alias= settings in the [Install] section, and DefaultInstance= for template
units). This means they are not meant to be enabled using systemctl.

Possible reasons for having this kind of units are:
• A unit may be statically enabled by being symlinked from another unit's
  .wants/ or .requires/ directory.
• A unit's purpose may be to act as a helper for some other unit which has
  a requirement dependency on it.
• A unit may be started when needed via activation (socket, path, timer,
  D-Bus, udev, scripted systemctl call, ...).
• In case of template units, the unit is meant to be enabled with some
  instance name specified.

which makes sense since it's a dbus service.

183amir commented 5 years ago

I noticed that this happens only in my app (Gahshomar) and not using other flatpak apps (e.g. Fondo). Here is what I am getting:

(gahshomar:3): Gtk-DEBUG: 00:32:36.966: Failed to get an inhibit portal proxy: Error calling StartServiceByName for org.freedesktop.portal.Desktop: Timeout was reached

If I kill xdg-desktop-portal and xdg-desktop-portal-gtk, and I run Fondo, the portal processes are opened quickly and Fondo runs. However when I kill those processes and run Gahshomar it hangs for 25 seconds and outputs the error above and those processes will be running.

HambaliArab commented 4 years ago

Duplicate of #

183amir commented 4 years ago

@HambaliArab duplicate of what?

183amir commented 4 years ago

I am still having this issue by the way. I would really appreciate any help and feedback.

horatiog commented 3 years ago

@183amir I don't know if you're still having the issue but I have some information and hopefully a solution, as I experienced the same issue on Arch. After reviewing the logs and debug output for xdg-desktop-portal, I found that it was throwing an error about not being able to connect to pipewire which xdg-desktop-portal uses for some multimedia functions. I installed the version of pipewire from the git repo (pipewire-git in the AUR) and the error went away and my programs now launch without the delay. So, I don't think this is a flatpak/xdg-desktop-portal issue, I think it's a problem with pipewire that has apparently been fixed. Not a developer, but I hope this helps.

183amir commented 3 years ago

Thank you for your comment. I tried it and I still get:

(gahshomar:2): Gdk-WARNING **: 10:37:26.585: Settings portal not found: Error calling StartServiceByName for org.freedesktop.portal.Desktop: Timeout was reached

and the desktop hangs. Now it hangs even when portal is already running.

183amir commented 3 years ago

Running: dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY fixes the hang though. I don't know why this command needs to be run manually. Putting this command in ~/.xprofile runs it at login.

harmathy commented 3 years ago

I stumbled over this report, while searching for a solution to broken screen sharing on my Arch Linux machine. @horatiog your comment was the key to fixing this issue for me. I noticed, that there was a pipewire.conf.pacnew indicating a changed pipewire default configuration. Applying the new configuration totally fixed this issue:

sudo mv /etc/pipewire/pipewire.conf{.pacnew,}

I hope this is useful for other Arch Linux user coming across this issue.

183amir commented 3 years ago

I have tested this on Fedora and everything works there. On ArchLinux, please refer to https://github.com/flatpak/xdg-desktop-portal-gtk/issues/107#issuecomment-766322266

duartec3000 commented 3 years ago

@harmathy I love you! the new pipewire configuration has solved 2 very annoying Issues for me:

Notes: There is no need to add dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY to .xprofile if you have the current flatpak package and related dependencies.

I have been actively searching for a solution for more than a week thank you so much @harmathy !!!

harmathy commented 3 years ago

@harmathy I love you! the new pipewire configuration has solved 2 very annoying Issues for me:

* Flatpak applications launching very slowly 30+ secs

* URLs/Links not working when clicked inside Flatpak applications

Notes: There is no need to add dbus-update-activation-environment --systemd DBUS_SESSION_BUS_ADDRESS DISPLAY XAUTHORITY to .xprofile if you have the current flatpak package and related dependencies.

I have been actively searching for a solution for more than a week thank you so much @harmathy !!!

You're welcome 😄

irfan798 commented 3 years ago

I stumbled over this report, while searching for a solution to broken screen sharing on my Arch Linux machine. @horatiog your comment was the key to fixing this issue for me. I noticed, that there was a pipewire.conf.pacnew indicating a changed pipewire default configuration. Applying the new configuration totally fixed this issue:

sudo mv /etc/pipewire/pipewire.conf{.pacnew,}

I hope this is useful for other Arch Linux user coming across this issue.

Wow, My telegram-desktop was starting 60 seconds delayed and file dialogs was freezing the app. Also Firefox with GTK_USE_PORTAL=1 env variable was giving this error on file dialogs

Can't open portal file chooser: GDBus.Error:org.freedesktop.DBus.Error.TimedOut: Failed to activate service 'org.freedesktop.portal.Desktop': timed out (service_start_timeout=120000ms)

I was searching and debugging for hours and this solved all the issues. Thank you @harmathy !!

resolritter commented 3 years ago

I stumbled over this report, while searching for a solution to broken screen sharing on my Arch Linux machine. @horatiog your comment was the key to fixing this issue for me. I noticed, that there was a pipewire.conf.pacnew indicating a changed pipewire default configuration. Applying the new configuration totally fixed this issue:

sudo mv /etc/pipewire/pipewire.conf{.pacnew,}

I hope this is useful for other Arch Linux user coming across this issue.

Relevant for Arch: this did not work for me because the .pacnew file was using a format which isn't compatible with the current version. See https://github.com/flatpak/xdg-desktop-portal/issues/570#issuecomment-860323967 for context.

ivilata commented 3 years ago

In my case, on a Debian Sid box, the dbus-update-activation-environment didn't work but purging xdg-desktop-portal did.

pedroapero commented 2 years ago

@ivilata Simple, it worked for me too, thank you!

tzcrawford commented 1 year ago

Author

183amir commented on Jan 24, 2021

As it currently stands, the arch wiki page on xinit asserts that you should be running all of the scripts in /etc/X11/xinit/xinitrc.d/ if you are running startx manually with custom settings. Essentially one of those scripts (50-systemd-user.sh) runs your aforementioned command:

systemctl --user import-environment DISPLAY XAUTHORITY
if command -v dbus-update-activation-environment >/dev/null 2>&1; then
    dbus-update-activation-environment DISPLAY XAUTHORITY
fi

So you might consider adding the terminal if block from the template xinitrc into yours:

if [ -d /etc/X11/xinit/xinitrc.d ] ; then
    for f in /etc/X11/xinit/xinitrc.d/?*.sh ; do
        [ -x "$f" ] && . "$f"
    done
    unset f
fi