PaulCombal / SamRewritten

Steam Achievement Manager For Linux. Rewritten in C++.
GNU General Public License v3.0
321 stars 29 forks source link

Does not work when launched in flatpak with `--appimage-extract-and-run` #128

Closed soredake closed 1 year ago

soredake commented 2 years ago

1.1 version with ubuntu shows UI for a 2-3 seconds then crashes.

[📦 com.valvesoftware.Steam Изображения]$ LC_ALL=C ./SamRewritten-ab06374-x86_64.AppImage  --appimage-extract-and-run
[PID:68 TRD:140419307069568 TME:5.9e-05]        PerfMon started.
[PID:68 TRD:140419307069568 TME:0.022123]       Globals initialized.
[PID:68 TRD:140419307069568 TME:0.138479]       Starting library parsing.
CCrossProcessPipe::BWrite wrote too few bytes: 32 (Broken pipe).  Continuing.
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : Fatal assert; application exiting
src/common/pipes.cpp (883) : Fatal assert; application exiting
_ExitOnFatalAssert
assert_20220523201424_3.dmp[83]: Uploading dump (out-of-process)
/tmp/dumps/assert_20220523201424_3.dmp
[📦 com.valvesoftware.Steam Изображения]$ assert_20220523201424_3.dmp[83]: Finished uploading minidump (out-of-process): success = yes
assert_20220523201424_3.dmp[83]: response: Discarded=1
assert_20220523201424_3.dmp[83]: file ''/tmp/dumps/assert_20220523201424_3.dmp'', upload yes: ''Discarded=1''

2.1 version does not shows UI, just crashes.

[📦 com.valvesoftware.Steam Изображения]$ LC_ALL=C ./SamRewritten-Ubuntu_18.04--d29ad13-x86_64.AppImage --appimage-extract-and-run

(samrewritten:90): Gtk-WARNING **: 20:16:23.385: Could not load a pixbuf from icon theme.
This may indicate that pixbuf loaders or the mime database could not be found.
**
Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /run/host/share/icons/breeze/status/16/image-missing.svg: Unable to load image-loading module: /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so: /usr/lib/x86_64-linux-gnu/librsvg-2.so.2: undefined symbol: cairo_font_options_get_variations (gdk-pixbuf-error-quark, 5)
Bail out! Gtk:ERROR:../../../../gtk/gtkiconhelper.c:494:ensure_surface_for_gicon: assertion failed (error == NULL): Failed to load /run/host/share/icons/breeze/status/16/image-missing.svg: Unable to load image-loading module: /usr/lib/x86_64-linux-gnu/gdk-pixbuf-2.0/2.10.0/loaders/libpixbufloader-svg.so: /usr/lib/x86_64-linux-gnu/librsvg-2.so.2: undefined symbol: cairo_font_options_get_variations (gdk-pixbuf-error-quark, 5)
/tmp/appimage_extracted_56ecf886f403435d53dd83759e923bb4/AppRun: line 8:    90 Aborted                 (core dumped) ${SCRIPT_PATH}/samrewritten $@
PaulCombal commented 2 years ago

Hi, I had no idea this even existed. What are you trying to accomplish? BTW maybe I'll make a few updates in the following months adding flatpak support. MAYBE

soredake commented 2 years ago

@PaulCombal i'm to launch samrewritten app inside steam flatpak, as obviously samrewritten cannot communicate with steam flatpak from outsite. AppImage requires fuse, which cannot be installed in flatpak, so i'm using this command line swich trying to launch samrewritten in flatpak.

https://github.com/flathub/net.lutris.Lutris/issues/200#issuecomment-1106423177

soredake commented 2 years ago

Packaging samrewritten as flatpak will not help communicating with flatpaked steam IIRC as flatpak app<-->flatpak app communication is not possible.

Some thoughts on flat<-->flat communication https://github.com/flatpak/flatpak/issues/2723

soredake commented 2 years ago

I've tried to launching this build (which works on fedora kde 36) on host while steam is running, i've symlinked ~/.var/app/com.valvesoftware.Steam/.local/share/Steam/ to ~/.steam so samrewritten can find steam directory. But it's still cannot fully communicate with steam

❯ ./SamRewritten-Debian_bookworm-2a9fe6f-x86_64.AppImage
Gtk-Message: 09:42:57.688: Failed to load module "colorreload-gtk-module"
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : Fatal assert; application exiting
src/common/pipes.cpp (883) : Fatal assert; application exiting
Uploading dump (in-process) [proxy '']
/tmp/dumps/assert_20220524094259_3.dmp
success = yes
response:  Discarded=1
Could not find steamerrorreporter binary. Any minidumps will be uploaded in-process_ExitOnFatalAssert
soredake commented 2 years ago

Tried running newer appimage inside flatpak

[📦 com.valvesoftware.Steam Изображения]$ ./SamRewritten-Debian_bookworm-2a9fe6f-x86_64.AppImage --appimage-extract-and-run
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : fatal stalled cross-thread pipe (pipe is disconnected).
src/common/pipes.cpp (883) : Fatal assert; application exiting
src/common/pipes.cpp (883) : Fatal assert; application exiting
assert_20220524094710_3.dmp[33]: Uploading dump (out-of-process)
/tmp/dumps/assert_20220524094710_3.dmp
_ExitOnFatalAssert
[📦 com.valvesoftware.Steam Изображения]$ assert_20220524094710_3.dmp[33]: Finished uploading minidump (out-of-process): success = yes
assert_20220524094710_3.dmp[33]: response: Discarded=1
assert_20220524094710_3.dmp[33]: file ''/tmp/dumps/assert_20220524094710_3.dmp'', upload yes: ''Discarded=1''

dobey commented 1 year ago

The issue here is not that Steam is a flatpak, but that the Steam SDK in SamRewritten seems to be outdated. I've replaced the libsteam_api.so locally, and added a check for the flatpak steam path, and it will connect and list most of my games (some do not appear in the list for some reason), and then when I try to view the achievements, it crashes with:

[S_API] SteamAPI_Init(): SteamAPI_IsSteamRunning() did not locate a running instance of Steam.
[S_API FAIL] SteamAPI_Init() failed
An error occurred launching the Steam API. Aborting.
Read pipe encountered fatal error.
dobey commented 1 year ago

Well, I managed to sort of get it working. Firstly, the SDK needs updating and built against the new version. Then, it was necessary to copy the binary and data files into the Steam flatpak's files directory, as well as the libraries needed, along with a wrapper script fit for running inside the flatpak, as SamRewritten is not written very well when it comes to finding things like the glade UI and such. Then I was able to run the app with a command like:

flatpak run --branch=stable --arch=x86_64 --command=/app/bin/samrewritten-wrapper --file-forwarding com.valvesoftware.Steam

However, to modify achievements on one game, and then another, one must exit and restart both Steam and SamRewritten each time,as the game gets stuck in a "running" state in Steam, while SamRewritten doesn't seem to handle stopping the game properly or starting a different one instead.

Not the prettiest solution, and certainly not feasible for SamRewritten to need to be run under the context of the Steam flatpak, but at least it enabled me to accomplish what I needed this app for in the first palce, after a fashion.

soredake commented 1 year ago

If samrewritten will be able to work with flatpak'ed steam without being launched inside steam flatpak it will be great.

PaulCombal commented 1 year ago

If samrewritten will be able to work with flatpak'ed steam without being launched inside steam flatpak it will be great.

I'll get back to it when Conan will be a bit more mature. I still have some plans for SamRewritten! https://github.com/PaulCombal/SamRewritten/projects/1

As always, contributors welcome

Arcitec commented 1 year ago

maybe I'll make a few updates in the following months adding flatpak support. MAYBE

@PaulCombal I totally understand if you don't have any time or interest in Flatpak. So I don't expect anything. But will say this: Steam Flatpak is becoming the most popular way to run Steam on Linux. It's a cross-distro way to ensure that you have working anticheat (glibc version), and everything generally works a lot better than native Steam.

The work of @dobey above is really good starter hints for Flatpak support.

In general, the proper way to write Flatpak additions for Steam is to create them as a "Steam Utility" package, such as this one:

https://github.com/flathub/com.valvesoftware.Steam.Utility.steamtinkerlaunch

From what I understand, there's something in the YML file or naming of the package which makes Steam's Flatpak "merge" its contents with that Flatpak, so that Steam can see and use the binaries provided by the utilities.

Therefore SamRewritten could be a Utility. And would be visible inside the Steam Flatpak, and would then be runnable via a command similar to what dobey did (but probably simpler than that).

Either way, I totally understand if nobody wants to try this. I'm personally gonna use a Windows VM to install Windows Steam and a Windows achievement editor tool, because I don't wanna mix Native Steam and Flatpak Steam on my Linux OS. That's just dirty and would lead to confusing extra folders on disk. :)

Edit: I used https://github.com/gibbed/SteamAchievementManager in a Windows VM. The Linux Steam still showed the achievements in the "game overview" page, but if I clicked "view my achievements" on Linux, I saw that they were all properly reset, so that's just a graphical delay issue. Resetting achievements via a Virtual Machine worked perfectly.