flathub / com.valvesoftware.Steam

https://flathub.org/apps/details/com.valvesoftware.Steam
337 stars 70 forks source link

Native Steam client tries to launch VR games using the Flatpak version of Steam (which then obviously fails) #1144

Open SentineI opened 10 months ago

SentineI commented 10 months ago

Game information All VR games, such as "Wardens of the Amber Cage" (which is small & free to play, so it's an easy test case).
You obviously also need the "SteamVR" tool installed in the native Steam client.

Distribution name and version where applicable Ubuntu LTS 22.04 and Ubuntu LTS 20.04 . (If testing with 20.04 then beware that many VR games don't work with Proton 8.0-x, so you need to change to Proton 7.0-x.)

Flatpak info Flatpak 1.12.7 nvidia-535-86-05 default host

Problem description When both the native & Flatpak versions of Steam are installed, and only the native Steam client is being used, trying to run any VR games will fail, as the native Steam client tries to launch the VR game using the Flatpak version of Steam! The following symptoms are normally observed when trying to run a VR game:

  1. The SteamVR tool starts, if it wasn't already running.
  2. Steam seems to run a second time (and it's not obvious this is the Flatpak version, so originally I was blaming Valve)... and this typically causes the original native Steam to go off-line (e.g. on the Friends window).
  3. If the Flatpak version of Steam has the VR game installed (e.g. say due to using something like "mount --bind $HOME/.steam $HOME/.var/app/com.valvesoftware.Steam/.steam"), then the VR game starts in some fashion, but only visible on the monitor (not the VR headset) - often with black unresponsive windows, or if you are lucky the non-VR version of the game.

I'd thought Valve had broken VR support on Linux, because all VR games had stopped working since I'd last tried them, and it was not obvious to my untrained eye that the Flatpak version of Steam was starting. I'd tried reinstalling all sorts of things & changing various Steam settings, without any luck. I then went to the trouble of installing a clean version of Ubuntu on a spare HD I had, and found that strangely Steam VR games worked fine. So I went back to my normal Ubuntu installation, and tried to work-out where it was going wrong (starting the second copy of Steam), when I noticed a few things which hinted that maybe Flatpak might be involved.

But as I said, this was NOT obvious to the untrained eye, so if it's not possible to fix this for some reason, then there needs to be some kind of warning to not have the native Steam client installed at the same time as the Flatpak version. BTW, I had both installed because I wasn't sure how compatible the Flatpak version was compared to the native client, and so I wanted to compare them.

Does this issue reproduce with native Steam N/A

SentineI commented 5 months ago

When I said "run any VR games will fail" I meant starting SteamVR Home, and from there (inside VR) selecting a game to run.

I have discovered that if I start SteamVR Home, take off my headset, and then start a VR game from the Steam window, the game starts just fine in VR!

SentineI commented 5 months ago

I have now been able to identify the problem, and work-around it. This is the problem:

~$ grep MimeType /var/lib/flatpak/exports/share/applications/com.valvesoftware.Steam.desktop
MimeType=x-scheme-handler/steam;x-scheme-handler/steamlink;
~$ xdg-mime query default x-scheme-handler/steam
com.valvesoftware.Steam.desktop

Because it means when SteamVR Home executes a command like this:

xdg-open steam://rungameid/883560

It tries to start the VR game in the Flatpak version of Steam. (I'm not sure why the Flatpak's desktop file takes priority over the native "/usr/share/applications/steam.desktop" file, possibly the Flatpak folder is just declared after the native folder in some list.)

My solution is to edit the Flatpak "com.valvesoftware.Steam.desktop" file, comment-out the MimeType line, and then update the MIME database:

~$ sudo sed -i "s/^MimeType=/#MimeType=/g" /var/lib/flatpak/exports/share/applications/com.valvesoftware.Steam.desktop
~$ grep MimeType /var/lib/flatpak/exports/share/applications/com.valvesoftware.Steam.desktop
#MimeType=x-scheme-handler/steam;x-scheme-handler/steamlink;
~$ sudo update-desktop-database /var/lib/flatpak/exports/share/applications
~$ xdg-mime query default x-scheme-handler/steam
steam.desktop

The Flatpak version of Steam could permanently fix this by simply removing "x-scheme-handler/steam;" from the "MimeType" line of the ".desktop" file it installs. (That will have some minor downsides, but they seem far smaller than totally breaking all SteamVR games.)

Arcitec commented 1 week ago

I randomly stumbled onto your thread for another reason.

Great work identifying the issue.

There are problems with your suggested solution though. Game launchers such as Cartridges requires that the Steam Flatpak listens to steam:// URLs or the games won't launch.

I have another proposal for a fix: Don't use both the Flatpak and Native versions of Steam. It is precisely the reason why it gets confused about who should handle steam:// links. Alternatively, you can use a command line application (I can't remember the command right now) to set which application .desktop shortcut file will handle steam:// MIME links. You don't need to edit any .desktop files! Just manually run one command to tell GNOME which one to prefer for steam:// links.

SentineI commented 4 hours ago

Thanks for the suggestion. I don't know if this is what you were thinking of, but the following command seems to be an alternative to editing the .desktop file:

~$ xdg-mime default steam.desktop x-scheme-handler/steam
~$ xdg-mime query default x-scheme-handler/steam
steam.desktop

I haven't yet tested if it survives a reboot, but I assume it will...

And the following GNOME command provides a bit more info:

~$ gio mime x-scheme-handler/steam
Default application for “x-scheme-handler/steam”: steam.desktop
Registered applications:
    com.valvesoftware.Steam.desktop
    steam.desktop
Recommended applications:
    com.valvesoftware.Steam.desktop
    steam.desktop