SUMMARY For some reason snapd doesn't allow dbus activating of xdg-desktop-portal and returns AccessDenied to any request. Qt checks the returned error[1] and if it is not ServiceUnknown, Qt doesn't try to open URL through xdg-open, which encounters into situation that URLs doesn't open until some other app tries to access xdg-desktop-portal. [1] https://github.com/qt/qtbase/blob/dev/src/platformsupport/services/genericunix/qgenericunixservices.cpp#L192 STEPS TO REPRODUCE 1. Don't have xdg-desktop-portal running 2. Open some URL through a snap based on kde-neon extension OBSERVED RESULT URL doesn't open EXPECTED RESULT URL opens in default browser SOFTWARE/OS VERSIONS Linux/KDE Plasma: KDE neon 5.18 (available in About System) KDE Plasma Version: 5.18.4 KDE Frameworks Version: 5.69.0 Qt Version: 5.14.1 ADDITIONAL INFORMATION
KDE upstream bug
Oops, link to the Qt bug: https://bugreports.qt.io/browse/QTBUG-81597
Even if I manually start xdg-desktop-portal-kde, this still happens for me. :( Is this 100% an upstream Qt issue, or is there anything we can do on the KDE side? Did the KDE snap and flatpak packages just suddenly get an updated Qt to trigger this issue or something?
The bug I'm describing here was fixed on snapd side with https://github.com/snapcore/snapd/commit/d644659aa7f0605d6fcdfd80fa45d1a54bbfda8d long time ago. If anyone is interesting why such kind of issues happen with Qt, but not gtk applications (xdg-desktop-portal is not the only problem here, I've also experienced such a problem with org.freedesktop.Notifications service on MATE systems), that's because glib's GDBusProxy class emits a org.freedesktop.DBus.StartServiceByName which is allowed by snapd, so it happens by the time a gtk application does request, the service is already started. Qt has nothing like this. So I'm wrapping D-Bus calls with StartServiceByName calls in my applications for them to work nicely with snapd. This is still required for any calls except of xdg-desktop-portal as this was fixed only for xdg-desktop-portal from snapd side. But of course it doesn't mean opening files works with Qt and snap as there's still https://bugreports.qt.io/browse/QTBUG-83939, it's another bug though.