SpinShare / client-next

A modern cross-platform custom chart client for SpinShare
https://github.com/SpinShare
GNU Affero General Public License v3.0
2 stars 0 forks source link

Steamdeck / Linux Build #77

Closed LauraWebdev closed 6 months ago

LauraWebdev commented 8 months ago

Currently, the release pipeline does not package libwebkit2gtk into the executable to be able to be run on Linux without installing additional packages. This is especially bad since the SteamDeck (one of our target devices) do not allow installation of arbitrary packages.

As laid out in https://github.com/tryphotino/photino.Documentation/issues/18#issuecomment-1887471379, there seems to be a way to package the dependency itself.

LauraWebdev commented 8 months ago

I've put a copy of the packages into the SpinShareClient/lib/linux folder and extended the SpinShareClient.csproj to include those libs in the build (which it seemingly does, as seen by the bigger zip size). Testing on a real SteamDeck resulted in the error that libwebkit2gtk-4.1-0.so could not be loaded/found though.

Maybe we'll have to wait with this issue until @philippjbauer / @MikeYeager / @tryphotino have released their documentation for publishing under Linux in the future.

philippjbauer commented 8 months ago

Hi Laura! Over the last few days I dug deeper into the issue. Looking at the build output folder, do you find the library in the root of the output folder alongside the YourProjectName.dll file? Do you get a console window when you switch the OutputType from WinExe to Exe in your csproj file? The debug information could help nail this down. On the Steam Deck you should have a folder for your project in ~/.net/YourProjectName with folders that include your build output after extraction from single file. You should find the library in there.

It might help if you add the following code to your Program.cs (before calling PhotinoWindow) to force the current working path to the path the executable is in:

// This is more accurate than Directory.CurrentDirectory() to get the Working Directory
string entryAssemblyLocation = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

// Set the current directory to the location of the executable
// This may be necessary for the native libraries to load properly
Directory.SetCurrentDirectory(entryAssemblyLocation);
LauraWebdev commented 8 months ago

Hey @philippjbauer, thank's for stopping by!

.net folder

On the SteamDeck, there are two folders with a seemingly generated ID under ~/.net/SpinShareClient (probably my two builds) that both have the libwebkit2gtk.so and all it's dependencies. (Side question: Are these generated for each new build? Wouldn't that polute the home folder with many many copies of the same libs?)

Build folder

The published build (dotnet publish --configuration Release --runtime linux-x64) has two files,

SpinShareClient (290mb)
SpinShareClient.pdb (39kb)

This is the folder I've zipped and pushed to the SteamDeck for testing. Just building does give me the .so libraries alongside the applications .dll files.

Setting the workdir

Changing the type from WinExe to Exe and setting the workdir did not open a terminal, opening the executable through the terminal gave me a different error claiming libPhotino.Native.so can't be found now (this time, in the .net/ID folder though).

I do have a Sentry.io entry for the crash.

Unable to load shared library 'Photino.Native' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: 
libwebkit2gtk-4.1.so.0: cannot open shared object file: No such file or directory
/home/deck/Downloads/publish/Photino.Native.so: cannot open shared object file: No such file or directory
/home/deck/.net/SpinShareClient/TeFsfGnQCFNFldahwu4ZlXr7bmBEn8o=/libPhotino.Native.so: cannot open shared object file: No such file or directory
/home/deck/Downloads/publish/libPhotino.Native.so: cannot open shared object file: No such file or directory
/home/deck/.net/SpinShareClient/TeFsfGnQCFNFldahwu4ZlXr7bmBEn8o=/Photino.Native: cannot open shared object file: No such file or directory
/home/deck/Downloads/publish/Photino.Native: cannot open shared object file: No such file or directory
/home/deck/.net/SpinShareClient/TeFsfGnQCFNFldahwu4ZlXr7bmBEn8o=/libPhotino.Native: cannot open shared object file: No such file or directory
/home/deck/Downloads/publish/libPhotino.Native: cannot open shared object file: No such file or directory
LauraWebdev commented 6 months ago

This is working really well thanks to @philippjbauer publish script. Webkit2GTK doesn't seem to have proper Gamepad support yet, but that's a different issue and I've seen some movement about this in the Webkit Bugzilla.