Skip to content

Fix pack size related marshal issues.#1

Merged
Akarinnnnn merged 102 commits intoanycpu-2from
anycpu-packable-fix-align-by-conditionalmarshal
Feb 25, 2026
Merged

Fix pack size related marshal issues.#1
Akarinnnnn merged 102 commits intoanycpu-2from
anycpu-packable-fix-align-by-conditionalmarshal

Conversation

@Akarinnnnn
Copy link
Owner

@Akarinnnnn Akarinnnnn commented Oct 2, 2025

Our goal is to fix most callback system related marshal issues.

Added a conditional marshalling table to decide which alignment to use at runtime, this should fix most callback-retrieve related issues.

Struct parameters in interface methods are still need to fix. Edit: Completed.

I think we still need some effort to fix parameters, maybe we still have to ship different assembly for different platforms.
Edit: Parameter marshal is done, through it looks ugly.

Now the only problem is to find out which struct we treat it specially, in generation process.

And sorted Skippedlines
@Akarinnnnn
Copy link
Owner Author

Unfortunately this has turned out more complex than I envisioned. I'm willing to take a look at the parser myself but finding time will take longer. My apologies for the delay.

Do we accept every time Steamworks SDK updates we regenerate special struct table by C++ compiler? Or we just using this method to debug marshal bugs when it happens again?

Update pre-baked generator resource.

Make `SteamMarshallerTable` public.

Added `.editorconfig` to enforce style.
@sandsalamand
Copy link

It builds, but as soon as SteamManager.cs tries to load steam_api, it throws an error and crashes.

  ERROR: [Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.
  ERROR: System.DllNotFoundException: Unable to load shared library 'steam_api' 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: 
  ERROR: /usr/lib/dotnet/shared/Microsoft.NETCore.App/9.0.13/steam_api.so: cannot open shared object file: No such file or directory
  ERROR: /usr/lib/dotnet/shared/Microsoft.NETCore.App/9.0.13/libsteam_api.so: cannot open shared object file: No such file or directory
  ERROR: /usr/lib/dotnet/shared/Microsoft.NETCore.App/9.0.13/steam_api: cannot open shared object file: No such file or directory
  ERROR: /usr/lib/dotnet/shared/Microsoft.NETCore.App/9.0.13/libsteam_api: cannot open shared object file: No such file or directory
  ERROR: 
  ERROR:    at Steamworks.NativeMethods.SteamAPI_RestartAppIfNecessary(AppId_t unOwnAppID)
  ERROR:    at Steamworks.SteamAPI.RestartAppIfNecessary(AppId_t unOwnAppID)
  ERROR:    at SteamManager._EnterTree() in /home/sand/Documents/homunculus-fighters/MirageSteamworks/Runtime/SteamManager.cs:line 100<Node#27229423002>

@Akarinnnnn
Copy link
Owner Author

Akarinnnnn commented Feb 23, 2026 via email

@sandsalamand
Copy link

I'm on anycpu-packable-fix-align-by-conditionalmarshal

@Akarinnnnn
Copy link
Owner Author

Akarinnnnn commented Feb 24, 2026 via email

@sandsalamand
Copy link

sandsalamand commented Feb 24, 2026

Ok. In case this helps you, the steps that I followed to get that error above were:

  1. Replace StandaloneV2.0 pre-built DLL from Steamworks main fork with the DLL that I built from your fork using dotnet build Steamworks.NET.sln -c Release within StandaloneV3.0.
  2. Replace libsteam_api.so with the one from this fork.
  3. Remove my NativeLibrary.SetDllImportResolver hack from SteamManager.cs.
  4. Run the game.

@Akarinnnnn
Copy link
Owner Author

Akarinnnnn commented Feb 24, 2026

Ok. In case this helps you, the steps that I followed to get that error above were:

  1. Replace StandaloneV2.0 pre-built DLL from Steamworks main fork with the DLL that I built from your fork using dotnet build Steamworks.NET.sln -c Release within StandaloneV3.0.
  2. Replace libsteam_api.so with the one from this fork.
  3. Remove my NativeLibrary.SetDllImportResolver hack from SteamManager.cs.
  4. Run the game.

It's little hard for me to follow your steps, especially I use WSL2 for Linux testing that possibly hard to run Godot editor. But I remember Godot uses standard .NET SDK to build scripts. It can help you copy steam .so files to proper location, but it also stops you from manual replace them.

Though your step 1 and 2 successfully replaced original V2 files, it might still being overwritten by .NET SDK. Try modify your .csproj like this might help:
PackagedTest.zip

@Akarinnnnn
Copy link
Owner Author

Akarinnnnn commented Feb 24, 2026

Notably this line:

<PackageReference Include="Steamworks.NET.AnyCPU" Version="2025.162.7-a-socketmarshal.1" />

Replace Steamworks.NET(V2) with Steamworks.NET.AnyCPU(V3), and specify a correct version, your game will probably run @sandsalamand .

Copy link

@sandsalamand sandsalamand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible causes of the error

extension = ".dylib";
else
extension = ".so"; // I can't imagine what else platforms other than linux that
// Steamworks.NET.AnyCPU will run on, but let's be future proof
Copy link

@sandsalamand sandsalamand Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are adding the correct extension but not the lib prefix. On Linux and Mac the steam_api file is called libsteam_api .

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed these lines to:

string prefix = "lib";	// The library is called libsteam_api on Linux and MacOS

// Will be libsteam_api.so on Linux and libsteam_api.dylib on MacOS
string unixLibraryName = prefix + SysPath.ChangeExtension(libraryName, extension);

string path = SysPath.Combine(assemblyLocation, unixLibraryName);

It did not solve the problem, but I confirmed that it is now the correct name "libsteam_api.so" on Linux.

@ryan-linehan
Copy link

Notably this line:

<PackageReference Include="Steamworks.NET.AnyCPU" Version="2025.162.7-a-socketmarshal.1" />

Replace Steamworks.NET(V2) with Steamworks.NET.AnyCPU(V3), and specify a correct version, your game will probably run @sandsalamand .

I've got a Godot game building and ran it on a steam deck through steam with version 2025.162.6.b-socket.1 if it helps. I can try updating to this one to make sure it works on my demo project if it helps out at all

Move Any CPU native resolve logic to another file.

Minor changes to .editorconfig
@Akarinnnnn
Copy link
Owner Author

Notably this line:

<PackageReference Include="Steamworks.NET.AnyCPU" Version="2025.162.7-a-socketmarshal.1" />

Replace Steamworks.NET(V2) with Steamworks.NET.AnyCPU(V3), and specify a correct version, your game will probably run @sandsalamand .

I've got a Godot game building and ran it on a steam deck through steam with version 2025.162.6.b-socket.1 if it helps. I can try updating to this one to make sure it works on my demo project if it helps out at all

Your game is working right? Which version of Godot are you two using? There might be some version caused differences.

@Akarinnnnn Akarinnnnn dismissed Chicken-Bones’s stale review February 25, 2026 15:13

This PR is too large now, code style (#if order) will be discussed and fixed in upcoming PR.

@Akarinnnnn Akarinnnnn merged commit 6165318 into anycpu-2 Feb 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

7 participants