ValveSoftware / SteamOS

SteamOS community tracker
1.6k stars 70 forks source link

xauth cookie is not properly refresh switching between desktop/gaming modes #775

Closed pietrodicaprio closed 1 year ago

pietrodicaprio commented 2 years ago

Your system information

Please describe your issue in as much detail as possible:

I expect to be able, for example, to drag and drop files into flatpaks and open links (to browser) from flatpak apps.

Steps for reproducing this issue:

  1. Use a flatpak like Discord
  2. Try to open a link sent in a channel
  3. The link is not opened in a browser due to missing xdg portals

Solution

Provide xdg-desktop-portal-gtk by default, as many apps use it nevertheless the current DE, to avoid manual installation by the users

References

https://www.reddit.com/r/SteamDeck/comments/u2wofv/steamos_doesnt_come_with_xdgdesktopportalgtk/ https://twitter.com/MComandon/status/1521738318358011904

bertogg commented 2 years ago

@Bubu, thanks for testing.

Yes, the portal gets started before switching to desktop mode

The situation here is that I don't think that the portal should be started in game mode in general, so what I'm wondering is who is starting it.

This can happen with non-Steam games like in this example, so maybe this is all what's going on? If not, I would be interested in knowing who else is starting. From this comment I understand that this is happening simply by booting the device and switching to desktop mode.

Anyway, if the problem is the portal and not something else then I also think that it probably makes sense to stop it when entering the desktop session (no need to restart it, as it will be started automatically if needed).

Bubu commented 2 years ago

In this case xdg-desktop-portal seem s to be autostarted in game mode without running any (steam or non steam) games, yes.

bertogg commented 2 years ago

Simply booting the device starts the desktop portal? This certainly doesn't happen in my device. Can you check the journal and see when the process is started?

Bubu commented 2 years ago

This is the output of journalctl --user -b 0 -g "Started|Reached" I captured earlier. I'm pretty sure the 5 minute gap is the time between completing bootup and me tapping my steam user, and selecting desktop mode.

Sep 22 19:08:20 steamdeck systemd[1032]: Reached target Paths.
Sep 22 19:08:20 steamdeck systemd[1032]: Reached target Timers.
Sep 22 19:08:20 steamdeck systemd[1032]: Reached target Sockets.
Sep 22 19:08:20 steamdeck systemd[1032]: Reached target Basic System.
Sep 22 19:08:20 steamdeck systemd[1032]: Started D-Bus User Message Bus.
Sep 22 19:08:20 steamdeck systemd[1032]: Started gamemoded.
Sep 22 19:08:20 steamdeck systemd[1032]: Reached target Main User Target.
Sep 22 19:08:27 steamdeck systemd[1032]: Started PipeWire Multimedia Service.
Sep 22 19:08:27 steamdeck systemd[1032]: Started Multimedia Service Session Manager.
Sep 22 19:08:33 steamdeck systemd[1032]: Started sandboxed app permission store.
Sep 22 19:08:33 steamdeck systemd[1032]: Started flatpak document portal service.
Sep 22 19:08:33 steamdeck systemd[1032]: Started Portal service.
Sep 22 19:08:33 steamdeck systemd[1032]: Started PipeWire PulseAudio.
Sep 22 19:13:18 steamdeck systemd[1032]: Reached target Session services which should run early before the graphical session is brought up.
Sep 22 19:13:18 steamdeck systemd[1032]: Started Unlock kwallet from pam credentials.
Sep 22 19:13:18 steamdeck systemd[1032]: Started Baloo File Indexer Daemon.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Daemon.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Session Management Server.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Config Module Initialization.
Sep 22 19:13:18 steamdeck systemd[1032]: Started User preferences database.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Global Shortcuts Server.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Window Manager.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE Plasma Workspace.
Sep 22 19:13:18 steamdeck systemd[1032]: Reached target KDE Plasma Workspace Core.
Sep 22 19:13:18 steamdeck systemd[1032]: Started Proxies GTK DBus menus to a Plasma readable format.
Sep 22 19:13:18 steamdeck systemd[1032]: Started Handle legacy xembed system tray icons.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KActivityManager Activity manager Service.
Sep 22 19:13:18 steamdeck systemd[1032]: Started KDE PolicyKit Authentication Agent.
Sep 22 19:13:19 steamdeck systemd[1032]: Started Powerdevil.
Sep 22 19:13:19 steamdeck systemd[1032]: Reached target KDE Plasma Workspace.
Sep 22 19:13:19 steamdeck systemd[1032]: Reached target Current graphical user session.
Sep 22 19:13:19 steamdeck systemd[1032]: Started EV2 Screen Rotation Hack.
Sep 22 19:13:19 steamdeck systemd[1032]: Started IBus.
Sep 22 19:13:19 steamdeck systemd[1032]: Started Steam.
Sep 22 19:13:19 steamdeck systemd[1032]: Started Discover.
Sep 22 19:13:19 steamdeck systemd[1032]: Started Geoclue Demo agent.
Sep 22 19:13:19 steamdeck systemd[1032]: Started SteamOS Update Operating System Notifier.
Sep 22 19:13:19 steamdeck systemd[1032]: Reached target Startup of XDG autostart applications.
Sep 22 19:13:19 steamdeck systemd[1032]: Started /usr/lib/DiscoverNotifier.
Sep 22 19:13:19 steamdeck systemd[1032]: Started Accessibility services bus.
Sep 22 19:13:31 steamdeck systemd[1032]: Started nheko.
Sep 22 19:13:31 steamdeck systemd[1032]: Started flatpak session helper.
Sep 22 19:13:31 steamdeck systemd[1032]: Started app-flatpak-io.github.NhekoReborn.Nheko-3775.scope.
Sep 22 19:13:47 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-3881.scope.
Sep 22 19:13:47 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-3895.scope.
Sep 22 19:13:50 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-3909.scope.
Sep 22 19:13:50 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-3921.scope.
Sep 22 19:14:05 steamdeck systemd[1032]: Started Konsole - Terminal.
Sep 22 19:33:33 steamdeck systemd[1032]: Reached target Bluetooth.
Sep 22 19:34:05 steamdeck systemd[1032]: Started KRunner.
Sep 22 19:34:28 steamdeck systemd[1032]: Started /usr/bin/env.
Sep 22 19:35:03 steamdeck systemd[1032]: Started KRunner provider for baloo file indexer.
Sep 22 19:35:04 steamdeck systemd[1032]: Started KWrite - Text Editor.
Sep 22 19:35:32 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-4393.scope.
Sep 22 19:36:01 steamdeck systemd[1032]: Started Portal service.
Sep 22 19:36:01 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-4496.scope.
Sep 22 19:36:02 steamdeck systemd[1032]: Started app-flatpak-org.mozilla.firefox-4663.scope.
Sep 22 19:57:27 steamdeck systemd[1032]: Started Konsole - Terminal.
Sep 22 20:11:16 steamdeck systemd[1032]: Started Konsole - Terminal.
Sep 22 20:14:04 steamdeck systemd[1032]: Started KWrite - Text Editor.
Sep 22 20:14:21 steamdeck systemd[1032]: Started Dolphin - File Manager.

If you need other/more journal output I can get you that tomorrow. I also tried various variations of systemd --user list-dependencies and systemd-analyze but could not get systemd to tell me why xdg-desktop-portal.service gets started, only that it did, indeed, get started. I believe it's dbus activated (which I not very familiar with tbh) and maybe systemd doesn't have/save that info either in that case.

Bubu commented 2 years ago

I think I found a way to properly express "don't start this service until we reach desktop mode" in systemd. I disabled my earlier portal-restart.service again and instead did the following:

systemctl --user edit xdg-desktop-portal.service, then add the following drop-in config:

[Unit]
Requisite=graphical-session.target

Requisite= means that the unit can only be started when the listed ones are active but won't automatically try to start those.

@bertogg do you know where this needs to be added to be fixed on everyone's deck? The last fix did get applied here directly, but I'm not sure if that's the appropriate place for this as well: https://github.com/flatpak/xdg-desktop-portal/blob/main/src/xdg-desktop-portal.service.in

bertogg commented 2 years ago

Ok, finally I managed to reproduce the problem, I think it started to happen after I added some non-Steam games.

It's Steam itself that starts the portal:

steamdeck dbus-daemon[1028]: [session uid=1000 pid=1028] Activating via systemd: service name='org.freedesktop.portal.Desktop' unit='xdg-desktop-portal.service' requested by ':1.183' (uid=1000 pid=6896 comm="/home/deck/.local/share/Steam/ubuntu12_32/steam -s")

I'll investigate.

Bubu commented 2 years ago

Ah, nice.

I've noticed another thing. graphical-session.target is never stopped when you logout from the desktop mode/activete the return to game mode shortcut. So the portal is never stopped as a consequence of that and then on the next desktop session this is broken again :-/.

(This will work around this but not the second fix attempt I posted)

parkerlreed commented 2 years ago

Replying to https://github.com/ValveSoftware/SteamOS/issues/775#issuecomment-1256086364

I wonder if this is why you get the 4 seconds of desktop mouse on cold boot before game mode loads?

bertogg commented 2 years ago

I've noticed another thing. graphical-session.target is never stopped when you logout from the desktop mode/activete the return to game mode shortcut.

Are you sure about that? It works fine here.

Bubu commented 2 years ago

I was seeing that, yes. I noticed that with my second workaround/fix the second start to desktop mode had a broken portal again. I checked when returning to game mode the graphical-session target was still active and the xdg,-deaktop portal still running.

(I added Konsole as non-steam game to start it in game mode and check from there. Maybe doing that has some side effects.)

On September 25, 2022 8:11:20 PM GMT+02:00, Alberto Garcia @.***> wrote:

I've noticed another thing. graphical-session.target is never stopped when you logout from the desktop mode/activete the return to game mode shortcut.

Are you sure about that? It works fine here.

-- Reply to this email directly or view it on GitHub: https://github.com/ValveSoftware/SteamOS/issues/775#issuecomment-1257247828 You are receiving this because you were mentioned.

Message ID: @.***>

bertogg commented 2 years ago

FYI this is being worked on. In the meantime a workaround like this one should fix the problem.

(but you should also restart flatpak-session-helper and flatpak-portal)

CloneIX commented 2 years ago

I have the same problem with flatpack version of FF on Steam Deck.

This command makes it work again: systemctl restart --user xdg-desktop-portal

Do you need more info from me?

bertogg commented 2 years ago

No, I think I have all the information and a solution is being tested. For now you can try the workaround mentioned earlier. If you still have problems after the workaround let me know!

bertogg commented 2 years ago

Hi all! All these problems should be fixed in the latest image from the Main channel (20221028.1000). If anyone tries it and sees something strange or still broken, please let me know.

Thanks!

Bubu commented 2 years ago

@bertogg: thanks for the update. Can you share how this was solved in the end?

bertogg commented 2 years ago

@Bubu the most important change is that Gamescope is now managed by systemd so we can restart all the helper processes when switching to the desktop mode

nabel0 commented 2 years ago

Hi all! All these problems should be fixed in the latest image from the Main channel (20221028.1000). If anyone tries it and sees something strange or still broken, please let me know.

Thanks!

Hi!

Im on SteamOS "Preview" and it shows "20221003.100". Why is the "Preview" Version older then the "Main/Stable" version? IMG_3865

mindinsomnia commented 2 years ago

Opening links from Flatpaks still not working for me, just switched to preview 5 minutes before the timestamped of this comment, tried opening a link from discord with dbus monitor running and this was the result:

method call time=1667237513.934562 sender=:1.99 -> destination=org.freedesktop.portal.Desktop serial=23 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.OpenURI; member=OpenURI string "" string "https://github.com/ValveSoftware/SteamOS/issues/775" array [ ] error time=1667237513.934936 sender=:1.10 -> destination=:1.99 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=23 string "No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop"

nabel0 commented 2 years ago

Opening links from Flatpaks still not working for me, just switched to preview 5 minutes before the timestamped of this comment, tried opening a link from discord with dbus monitor running and this was the result:

method call time=1667237513.934562 sender=:1.99 -> destination=org.freedesktop.portal.Desktop serial=23 path=/org/freedesktop/portal/desktop; interface=org.freedesktop.portal.OpenURI; member=OpenURI string "" string "#775" array [ ] error time=1667237513.934936 sender=:1.10 -> destination=:1.99 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=23 string "No such interface “org.freedesktop.portal.OpenURI” on object at path /org/freedesktop/portal/desktop"

Did you read my comment above? @bertogg Said it is fixed in the Main channel (20221028.1000) version. Unfortunately "Preview" is 20221003.100.

mindinsomnia commented 2 years ago

Well I'm having the same issue on Stable, Beta and Preview. So I don't know.

lostgoat commented 2 years ago

Main builds are the equivalent of nightly builds and they are normally not accessible to users as they are untested and could result in a manual reflash of the unit being required.

Once this fix reaches the preview branch a relevant patch note will be added to let you know this fix is available.

parkerlreed commented 2 years ago

Main seems to be working well! Haven't had to restart anything upon entering desktop and links work

LOVING the updated base system and Plasma!

zocker-160 commented 2 years ago

@parkerlreed how did you switch to the main branch? I have only stable, beta and preview available.

parkerlreed commented 2 years ago

@parkerlreed how did you switch to the main branch? I have only stable, beta and preview available.

Enable Developer Options > Go to Developer Options > Enable Advanced Update Channels > Boom > Go back to list and select Main and update

zocker-160 commented 2 years ago

I can confirm that all the "open url" and "xdg-open" commands work again as expected on the main branch. Good work!

BlackRabbit22 commented 2 years ago

Can confirm too, everything is working as it should. No issues here. 👍

bertogg commented 2 years ago

I'm glad that the problem is fixed, it was a very annoying one and it took a while but hopefully it's gone for good. Thank you all for testing and helping with this!

@lostgoat is right however and I should have warned: images from the main branch are unstable so although this is fixed don't be surprised if other things are broken. So no need to hurry, you'll get the fix sooner or later.

kisak-valve commented 1 year ago

Closing as fixed per the last several comments. The fix related to this issue should be in SteamOS 3.4 and newer.

neogeographica commented 1 year ago

For anyone who did the workaround mentioned in https://github.com/ValveSoftware/SteamOS/issues/775#issuecomment-1129427573 , my experience is that you need to remove that configuration in order for things to work now with the new SteamOS release. (Personally I just removed the $HOME/.config/systemd/user/xdg-desktop-portal.service.d directory and rebooted.)

randomname42 commented 1 year ago

The flatpack version of Firefox on Steam Deck started being unable to "save as" in Desktop (nothing would happen when trying to save as). I don't use FF in game mode so I don't know if it would work there.

Librewolf (based off Firefox) from flatpak was also having the same issue, from a clean install (no extensions or anything). I uninstalled Librewolf because it didn't help.

For over a month I didn't have a solution, until I saw this mentioned somewhere: systemctl restart --user xdg-desktop-portal

Putting that into Konsole made FF start showing the "save as" dialog again.

Searching "systemctl restart --user xdg-desktop-portal" brought me to this issue. I'm on SteamOS 3.4.8 (stable) so it sounds like the problem was supposed to be fixed in the version I'm on. I don't know why I was experiencing this on 3.4.8.

I haven't checked yet if the problem returns. I'll update either way next time I switch from game mode to desktop mode.

parkerlreed commented 1 year ago

Yeah this has cropped back up on Main channel as well. I have to restart xdg-desktop-portal when switching to desktop to get the integration working again.

This has to be performed any time switching to desktop.

kisak-valve commented 1 year ago

Hello @randomname42, @parkerlreed, can one of you please open a new issue report with the details so that the newer regression can be tracked properly?