Skip to content

[BUG] DllNotFoundException when trying to invoke Skia in a Wasi Wasm Console app #3015

Open

Description

@enghch

Description

When trying to run a Wasi Console app that depends on SkiaSharp. It builds the single-file wasm just fine. I added the nuget package for the NativeAssets.WebAssembly. But when attempting to run, it throws:

"System.TypeInitializationException: TypeInitialization_Type, SkiaSharp.SKImageInfo --- System.DllNotFoundException: libSkiaSharp at SkiaSharp.SKImageInfo..cctor()

The NativeAssets has build targets for Blazor, but seems to be missing them for Wasi Wasm apps.

I'm on .NET 9 preview 6. Is there some workaround or something I'm missing? I attached a small repro project. I included the wasm file in case that's useful. If you're not familiar with wasi or wasitime, see in the instructions in the readme.
WasiSkiaSharpRepro.zip

Code

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <RuntimeIdentifier>wasi-wasm</RuntimeIdentifier>
    <OutputType>Exe</OutputType>
    <PublishTrimmed>true</PublishTrimmed>
	<WasmSingleFileBundle>true</WasmSingleFileBundle>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="SkiaSharp" Version="3.0.0-preview.4.1" />
    <PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.0.0-preview.4.1" />
  </ItemGroup>
</Project>

Version of SkiaSharp

2.88.3 (Current)

Last Known Good Version of SkiaSharp

2.88.2 (Previous)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Other (Please indicate in the description)

Platform / Operating System Version

Wasi Wasm

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. SashelI commented on Sep 24, 2024

    @SashelI

    Hi @enghch , I have a similar issue in Unity (see #3016 ) Do you think it's linked ?

  2. enghch commented on Sep 24, 2024

    @enghch
    Author

    Hmm! Good question. I was assuming the issue for me was because the NativeAssets package didn't include targets for wasi wasm. But maybe it's a larger issue with SkiaSharp in general?

  3. mattleibow commented on Nov 26, 2024

    @mattleibow
    Contributor

    The 3.x series should be including the native assets. Have you tried that yet?

  4. added
    os/WASM
    on Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/libSkiaSharp.nativeos/WASMtriage/triagedtype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions