Yellow-Dog-Man / brotli.net

the .net implement for the brotli algorithm
2 stars 2 forks source link

Remaining issues preventing Brotli.NET from loading on Linux #3

Open coolymike opened 1 month ago

coolymike commented 1 month ago

Currently, Brotli.NET does not work on Linux, causing in-game cloud syncing to be entirely broken. There are 2 issues preventing it from loading:

  1. https://github.com/dotnet/runtime/issues/15112, which causes the Linux native build to attempt loading brolib_x64.dll (a Windows-native DLL).
  2. The paths Brotli.NET attempts searching under Linux does not include the Resonite/Resonite_Data/Plugins directory, where brolib_x64.so is stored.

Once these two issues are resolved, Brotli.NET (and in turn, Brotli) function on Linux as expected. This allows for syncing records on the Linux native build of Resonite.

Issue 1

This is caused by RuntimeInformation.IsOSPlatform, which returns results for the compile target, and not the current runtime. According to the issue I linked above, this is intended behavior of the library. I verified this behavior by logging the output of that library against the output of #1 (on the Linux native build)

=============================
RuntimeInformation.IsOSPlatform says:
Windows: True
Linux: False

Custom implementation says:
Windows: False
Linux: True
=============================

This issue can be fixed either:

Issue 2

Brotli.NET is a .NET wrapper for the native Brotli library. Resonite includes this library for both Windows and Linux under Resonite/Resonite_Data/Managed/brolib_x64.dll for Windows and Resonite/Resonite_Data/Plugins/brolib_x64.so for Linux. The path for the Plugins directory is not used to search for the Brotli native library, as such Brotli.NET fails to find the library on Linux.

The paths Brotli.NET uses on Linux to find the native Brotli library include:

Resonite/Resonite_Data/Managed
Resonite/Resonite_Data/Managed/runtimes/linux/native
runtimes/linux/native
Resonite/Resonite_Data/Managed/../../runtimes/linux/native
Resonitebin/runtimes/linux/native
Resonite/Resonite_Data/Managed/runtimes/linux/native

These paths are almost the same as on Windows, except on Windows, win is used instead of linux.

This issue can be fixed either:

ProbablePrime commented 1 month ago

Thanks for the detailed research.

I'll resolve this when I can.

coolymike commented 1 month ago

After having used the workaround for a while, I have run into an issue with the Dash resetting when modified and synced on the Linux native build. I am unsure what causes this, and it most likely will need a different issue on the main repo.