goatcorp / XIVLauncher.Core

Cross-platform version of XIVLauncher, optimized for Steam Deck
GNU General Public License v3.0
118 stars 42 forks source link

Flatpak XIVLauncher can't detect Flatpak Steam #39

Open empjustine opened 1 year ago

empjustine commented 1 year ago

Related issue: https://github.com/flathub/dev.goats.xivlauncher/issues/26

SteamAPI_Init() fails because Flatpak XIVLauncher (dev.goats.xivlauncher) can't detect Flatpak Steam (com.valvesoftware.Steam).

[empjustine@huixtocihuatl ~]$ flatpak run 'dev.goats.xivlauncher' 
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
dlopen failed trying to load:
/var/home/empjustine/.steam/sdk64/steamclient.so
with error:
/var/home/empjustine/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
[S_API] SteamAPI_Init(): Sys_LoadModule failed to load: /var/home/empjustine/.steam/sdk64/steamclient.so
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
dlopen failed trying to load:
/var/home/empjustine/.steam/sdk64/steamclient.so
with error:
/var/home/empjustine/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
[S_API] SteamAPI_Init(): Sys_LoadModule failed to load: /var/home/empjustine/.steam/sdk64/steamclient.so

[empjustine@huixtocihuatl ~]$ ls -la /var/home/empjustine/.steam
ls: não foi possível acessar '/var/home/empjustine/.steam': Arquivo ou diretório inexistente
[empjustine@huixtocihuatl ~]$ LANG=C ls -la /var/home/empjustine/.steam
ls: cannot access '/var/home/empjustine/.steam': No such file or directory
[empjustine@huixtocihuatl ~]$ find ~/.var/app/com.valvesoftware.Steam/ -name 'steamclient.so'
/var/home/empjustine/.var/app/com.valvesoftware.Steam/.local/share/Steam/linux32/steamclient.so
/var/home/empjustine/.var/app/com.valvesoftware.Steam/.local/share/Steam/ubuntu12_32/steamclient.so
/var/home/empjustine/.var/app/com.valvesoftware.Steam/.local/share/Steam/linux64/steamclient.so

What I'm using

[empjustine@huixtocihuatl com.valvesoftware.Steam]$ cat /etc/os-release 
NAME="Fedora Linux"
VERSION="37.20230324.0 (Silverblue)"
ID=fedora
VERSION_ID=37
VERSION_CODENAME=""
PLATFORM_ID="platform:f37"
PRETTY_NAME="Fedora Linux 37.20230324.0 (Silverblue)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:37"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://silverblue.fedoraproject.org"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora-silverblue/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://github.com/fedora-silverblue/issue-tracker/issues"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=37
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=37
SUPPORT_END=2023-11-14
VARIANT="Silverblue"
VARIANT_ID=silverblue
OSTREE_VERSION='37.20230324.0'

[empjustine@huixtocihuatl com.valvesoftware.Steam]$ uname --all
Linux huixtocihuatl 6.2.7-200.fc37.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Mar 17 16:16:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

[empjustine@huixtocihuatl ~]$ flatpak list 
Nome                               ID de aplicativo                                  Versão          Ramo        Origem  Instalação
Vorta                              com.borgbase.Vorta                                v0.8.10         stable      flathub system
Czkawka                            com.github.qarmin.czkawka                         5.1.0           stable      flathub system
Szyszka                            com.github.qarmin.szyszka                         2.0.0           stable      flathub system
Microsoft Edge                     com.microsoft.Edge                                111.0.1661.54-1 stable      flathub system
Transmission                       com.transmissionbt.Transmission                   3.00            stable      flathub system
Steam                              com.valvesoftware.Steam                           1.0.0.75        stable      flathub system
XIVLauncher                        dev.goats.xivlauncher                             1.0.3.0         stable      flathub system
Transmission Remoto                io.github.TransmissionRemoteGtk                   1.5.1           stable      fedora  system
Podman Desktop                     io.podman_desktop.PodmanDesktop                   0.12.0          stable      flathub system
Fedora Media Writer                org.fedoraproject.MediaWriter                     5.0.4           stable      fedora  system
Fedora Platform                    org.fedoraproject.Platform                        37              f37         fedora  system
Freedesktop Platform               org.freedesktop.Platform                          21.08.18        21.08       flathub system
Freedesktop Platform               org.freedesktop.Platform                          22.08.9         22.08       flathub system
i386                               org.freedesktop.Platform.Compat.i386                              22.08       flathub system
Mesa                               org.freedesktop.Platform.GL.default               21.3.9          21.08       flathub system
Mesa                               org.freedesktop.Platform.GL.default               22.3.5          22.08       flathub system
Mesa (Extra)                       org.freedesktop.Platform.GL.default               22.3.5          22.08-extra flathub system
Mesa                               org.freedesktop.Platform.GL32.default             22.3.5          22.08       flathub system
Mesa (Extra)                       org.freedesktop.Platform.GL32.default             22.3.5          22.08-extra flathub system
openh264                           org.freedesktop.Platform.openh264                 2.1.0           2.0         flathub system
openh264                           org.freedesktop.Platform.openh264                 2.1.0           2.2.0       flathub system
Calculadora                        org.gnome.Calculator                              43.0.1          stable      fedora  system
Calendário                         org.gnome.Calendar                                43.1            stable      fedora  system
Caracteres                         org.gnome.Characters                              43.1            stable      fedora  system
Conexões                           org.gnome.Connections                             43.0            stable      fedora  system
Contatos                           org.gnome.Contacts                                43.0            stable      fedora  system
Visualizador de documentos         org.gnome.Evince                                  43.1            stable      fedora  system
Extensões                          org.gnome.Extensions                              43.beta         stable      fedora  system
Registos                           org.gnome.Logs                                    43.0            stable      fedora  system
Mapas                              org.gnome.Maps                                    43.2            stable      fedora  system
Sushi                              org.gnome.NautilusPreviewer                       43.0            stable      fedora  system
GNOME Application Platform versio… org.gnome.Platform                                                42          flathub system
GNOME Application Platform versio… org.gnome.Platform                                                43          flathub system
Editor de Texto                    org.gnome.TextEditor                              43.1            stable      fedora  system
Meteorologia                       org.gnome.Weather                                 43.0            stable      fedora  system
Analisador de uso de disco         org.gnome.baobab                                  43.0            stable      fedora  system
Relógios                           org.gnome.clocks                                  43.0            stable      fedora  system
Visualizador de imagens            org.gnome.eog                                     43.1            stable      fedora  system
Fontes                             org.gnome.font-viewer                             43.0            stable      fedora  system
Adwaita theme                      org.kde.KStyle.Adwaita                                            5.15-22.08  flathub system
KDE Application Platform           org.kde.Platform                                                  5.15-22.08  flathub system
QGnomePlatform                     org.kde.PlatformTheme.QGnomePlatform                              5.15-22.08  flathub system
QGnomePlatform-decoration          ….kde.WaylandDecoration.QGnomePlatform-decoration                 5.15-22.08  flathub system
tommadness commented 1 year ago

Due to how Flatpak sandboxes processes, there is nothing we can really do about that. You will need the non-Flatpak version of Steam to use XIVLauncher.

empjustine commented 1 year ago

It doesn't warn the user when "Use steam service" is toggled, it just logs (silently) to the console; that is usually not visible when just running a GUI.

Should it emit a visible GUI warning when "Use steam service" is toggled under flatpak then?

empjustine commented 1 year ago
[empjustine@huixtocihuatl XIVLauncher.Core]$ git status 
HEAD detached at 1.0.3
[empjustine@huixtocihuatl XIVLauncher.Core]$ dotnet publish -r linux-x64 src/XIVLauncher.Core
# (output supressed)
  XIVLauncher.Core -> /var/home/empjustine/XIVLauncher.Core/src/XIVLauncher.Core/bin/Debug/net6.0/linux-x64/publish/
[empjustine@huixtocihuatl XIVLauncher.Core]$ /var/home/empjustine/XIVLauncher.Core/src/XIVLauncher.Core/bin/Debug/net6.0/linux-x64/publish/XIVLauncher.Core 
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
dlopen failed trying to load:
/var/home/empjustine/.steam/sdk64/steamclient.so
with error:
/var/home/empjustine/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
[S_API] SteamAPI_Init(): Sys_LoadModule failed to load: /var/home/empjustine/.steam/sdk64/steamclient.so
[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
dlopen failed trying to load:
/var/home/empjustine/.steam/sdk64/steamclient.so
with error:
/var/home/empjustine/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
[S_API] SteamAPI_Init(): Sys_LoadModule failed to load: /var/home/empjustine/.steam/sdk64/steamclient.so
Unhandled exception. System.TypeInitializationException: The type initializer for 'Veldrid.Sdl2.Sdl2Native' threw an exception.
 ---> System.Exception: Didn't find library.
   at NativeLibraryLoader.NativeLibrary..ctor(IEnumerable`1 names)
   at Veldrid.Sdl2.Sdl2Native.LoadSdl2()
   at Veldrid.Sdl2.Sdl2Native..cctor()
   --- End of inner exception stack trace ---
   at Veldrid.Sdl2.Sdl2Native.SDL_Init(SDLInitFlags flags)
   at Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(WindowCreateInfo windowCI, GraphicsDeviceOptions deviceOptions, GraphicsBackend preferredBackend, Sdl2Window& window, GraphicsDevice& gd)
   at Veldrid.StartupUtilities.VeldridStartup.CreateWindowAndGraphicsDevice(WindowCreateInfo windowCI, GraphicsDeviceOptions deviceOptions, Sdl2Window& window, GraphicsDevice& gd)
   at XIVLauncher.Core.Program.Main(String[] args) in /var/home/empjustine/XIVLauncher.Core/src/XIVLauncher.Core/Program.cs:line 185
Abortado (imagem do núcleo gravada)

Still can't find Flatpak Steam even when running native.

tommadness commented 1 year ago

I said you need the non-Flatpak Steam. Native vs Flatpak XIVLauncher doesn't matter in this case.

Tsubajashi commented 1 year ago

im not too deep into how flatpak works, but isnt there a permission someone can check so that it has the chance to check for the steam service, ran as a flatpak? or how is xivlauncher trying to call into steam that its not possible in such a usecase?

Rioluuu commented 1 year ago

Found a (somewhat dirty) workaround.

mkdir -p ~/.steam/sdk64 ln ~/.var/app/com.valvesoftware.Steam/.steam/sdk64/steamclient.so ~/.steam/sdk64

and now XIVLauncher detects Flatpak Steam

Blooym commented 1 year ago

Going to take a look if we can incorporate a workaround for this into the launcher as I'd also love to move to flatpak steam myself

TheTee82 commented 1 year ago

Found a (somewhat dirty) workaround.

mkdir -p ~/.steam/sdk64 ln ~/.var/app/com.valvesoftware.Steam/.steam/sdk64/steamclient.so ~/.steam/sdk64

and now XIVLauncher detects Flatpak Steam

Switching from steam runtime to steam flatpak, I needed to remove the ~/.steam directory first and then I linked the whole .steam directory - might not be necessary but I don't think it won't be an issue. ln ~/.var/app/com.valvesoftware.Steam/.steam ~/

Tsubajashi commented 10 months ago

Found a (somewhat dirty) workaround. mkdir -p ~/.steam/sdk64 ln ~/.var/app/com.valvesoftware.Steam/.steam/sdk64/steamclient.so ~/.steam/sdk64 and now XIVLauncher detects Flatpak Steam

Switching from steam runtime to steam flatpak, I needed to remove the ~/.steam directory first and then I linked the whole .steam directory - might not be necessary but I don't think it won't be an issue. ln ~/.var/app/com.valvesoftware.Steam/.steam ~/

while it detects Flatpak Steam through this, i still encounter the issue that it doesnt tell steam that i close the game for some reason. do you have any workaround for that, too?

MiMillieuh commented 4 months ago

I managed to login and download the game with XIVLauncher and Steam both as flatpak with this link : ln ~/.var/app/com.valvesoftware.Steam/.steam/steam/linux64/steamclient.so ~/.steam/sdk64/

From this point you should be able to login and launch the game (if steam is running). however if you want to launch it from steam, we need to lower a little the steam sandbox :

And to launch it via steam you can add this permission to steam : sudo flatpak override com.valvesoftware.Steam --talk-name=org.freedesktop.Flatpak sudo flatpak override com.valvesoftware.Steam --socket=session-bus

Then you can add a dummy shortcut (doesn't matter what we'll change everything.)

Edit the shortcut and in target add : flatpak-spawn --host /bin/flatpak run dev.goats.xivlauncher and in the launch options add : XL_SECRET_PROVIDER=FILE %command% run --parent-expose-pids --parent-share-pids --parent-pid=1 --branch=stable --arch=x86_64 --command=xivlauncher dev.goats.xivlauncher (it seem to not work as intended however.)

image

The only thing that doesn't work is that when you close ffxiv it will still say that the game is running on steam and killing it will crash steam.

klack commented 2 weeks ago

I managed to login and download the game with XIVLauncher and Steam both as flatpak with this link : ln ~/.var/app/com.valvesoftware.Steam/.steam/steam/linux64/steamclient.so ~/.steam/sdk64/

This worked perfectly. Flatpak is great, but it's required permissions often go undocumented.

reiichi001 commented 2 weeks ago

This worked perfectly. Flatpak is great, but it's required permissions often go undocumented.

That's not using a flatpak in the intended manner. That's skirting around it entirely which is why we don't have anything related to that in XIVLauncher.Core's documentation/FAQs. What this does is completely bypass the flatpak environment altogether by making a link to where the non-flatpak application's files would have been.

MiMillieuh commented 2 weeks ago

This worked perfectly. Flatpak is great, but it's required permissions often go undocumented.

That's not using a flatpak in the intended manner. That's skirting around it entirely which is why we don't have anything related to that in XIVLauncher.Core's documentation/FAQs. What this does is completely bypass the flatpak environment altogether by making a link to where the non-flatpak application's files would have been.

That's a workaround we don't have a proper solution... or if anyone does then just write it down :)

A workaround is supposed to be a temporary solution. this should not close the issue. especially since it's not perfect and has it's flaws and drawbacks.

klack commented 2 weeks ago

This worked perfectly. Flatpak is great, but it's required permissions often go undocumented.

That's not using a flatpak in the intended manner. That's skirting around it entirely which is why we don't have anything related to that in XIVLauncher.Core's documentation/FAQs. What this does is completely bypass the flatpak environment altogether by making a link to where the non-flatpak application's files would have been.

Yes, so it could be possible for the FFXIVLauncher flatpak to infect the Steam binary. Would it be possible to make it read only? I think this is still safer, because when I am not using FFXIV, steam is protected.

There must be a proper way for one flatpak to talk to another.

MiMillieuh commented 2 weeks ago

This worked perfectly. Flatpak is great, but it's required permissions often go undocumented.

That's not using a flatpak in the intended manner. That's skirting around it entirely which is why we don't have anything related to that in XIVLauncher.Core's documentation/FAQs. What this does is completely bypass the flatpak environment altogether by making a link to where the non-flatpak application's files would have been.

Yes, so it could be possible for the FFXIVLauncher flatpak to infect the Steam binary. Would it be possible to make it read only? I think this is still safer, because when I am not using FFXIV, steam is protected.

There must be a proper way for one flatpak to talk to another.

The good way of doing it would be to use portals but if the portal doesn't exist or if the protocol isn't well supported by the orignal devs (in that case steam) it's really tricky... discord had some workaround too for RPC. It's also up to flatpak to allow some more stuff to be exposed. when devs targets linux, they don't always target flatpak as many package are maintained by a person that only do that on the project (probably cause flathub verification process is a nightmare)

So short answer : using the portal standard (if it's even possible with steam.)