Skip to content

Conversation

@thibaudio
Copy link

Hi!

As the title says, I'm trying to add browser-wasm support via NativeAOT-LLVM.
It looks like the library is built correctly, and I reference it with an updated Sample/Shapes.csproj:

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <OutputType>Exe</OutputType>
        <TargetFramework>net9.0</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>
    </PropertyGroup>

    <PropertyGroup>
        <IsBrowser>true</IsBrowser>
        <IsAotCompatible>false</IsAotCompatible>
        <PublishTrimmed>true</PublishTrimmed>
        <SelfContained>true</SelfContained>
        <MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
        <DefineConstants>EMSCRIPTEN</DefineConstants>
    </PropertyGroup>
    
    <ItemGroup>
        <PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
        <PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="10.0.0-*" />
        <PackageReference Include="FosterFramework" Version="0.2.3" GeneratePathProperty="true"/>
        <DirectPInvoke Include="FosterPlatform" />
        <DirectPInvoke Include="SDL3" />
        <NativeLibrary Include="$(PkgFosterFramework)\runtimes\browser-wasm\native\libFosterPlatform.a" />
        <NativeLibrary Include="$(PkgFosterFramework)\runtimes\browser-wasm\native\libSDL3.a" />
    </ItemGroup>
</Project>

For the moment, the game doesn't launch in the browser, with the following error, apparently referencing the main function:
SES_UNCAUGHT_EXCEPTION: RuntimeError: indirect call signature mismatch

Will continue to work on this next week, until then I'll be happy to get any insights!

@NoelFB
Copy link
Collaborator

NoelFB commented Jul 18, 2025

Hey, this sounds cool! I'm definitely open to this - however, I'm not sure how feasible this is right now as SDL_GPU doesn't have a web renderer yet (webgl or webgpu). Until then I'm not sure it's possible to get anything on the screen?

@thibaudio
Copy link
Author

Hey, this sounds cool! I'm definitely open to this - however, I'm not sure how feasible this is right now as SDL_GPU doesn't have a web renderer yet (webgl or webgpu). Until then I'm not sure it's possible to get anything on the screen?

I'm not sure 😅
I've seen this project in c++ that managed to display something, but maybe I'm mistaken: https://github.com/Ravbug/sdl3-sample

@NoelFB
Copy link
Collaborator

NoelFB commented Jul 18, 2025

Ah, yeah that is using the SDL_Renderer, which I believe does have webgl support. We're using the more full-featured SDL_GPU (which is closer to actual D3D12/Vulkan/Metal syntax) but it currently doesn't have a web backend. That said, the rest should be able to work, and at some point I assume SDL_GPU will have a web rendering backend, but we'll see.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants