Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Unable to load library 'libSkiaSharp'. #2758

Open
1 task done
jakobeazy opened this issue Feb 15, 2024 · 8 comments
Open
1 task done

[BUG] Unable to load library 'libSkiaSharp'. #2758

jakobeazy opened this issue Feb 15, 2024 · 8 comments
Labels

Comments

@jakobeazy
Copy link

jakobeazy commented Feb 15, 2024

Description

using svg.skia on anASP.NET website i get the following error:
Exception message: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
Unable to load library 'libSkiaSharp'.

The strange thing is that debugging the code locally, it works, but when deploying it to a server it fails with this error.
The versions i an using:
Svg.Skia: 1.0.0.13
SkiaSharp: 2.88.6
SkiaSharp.HarfBuzz: 2.88.6
SkiaSharp.NativeAssets.macOS: 2.88.6
SkiaSharp.NativeAssets.Win32: 2.88.6

the project is a .NET Framework 4.7.2
I can't figure out why it can run locally and not remote.

Code

The best way to share code for larger projects is a link to a GitHub repository: https://github.com/user/repo/tree/bug-123

But, you can also share a short block of code here:

// some C# code here

You can also share some XAML:

<!-- xaml code here -->

Expected Behavior

No response

Actual Behavior

No response

Version of SkiaSharp

Other (Please indicate in the description)

Last Known Good Version of SkiaSharp

Other (Please indicate in the description)

IDE / Editor

Visual Studio (Windows)

Platform / Operating System

Windows

Platform / Operating System Version

Windows Server 2016 v1607

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@jakobeazy
Copy link
Author

jakobeazy commented Feb 20, 2024

This is the complete call stack:

Exception information:

    Exception type: TypeInitializationException
    Exception message: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.
   at Svg.Skia.SKSvgSettings..ctor()
   at Svg.Skia.SKSvg..ctor()
   at FaellesKode.Generelt.SvgConverter.SaveAsPng(Stream file, String filePath) in D:\a\1\s\EazyProjectCode\EazyFaellesKode\Generelt\SvgConverter.cs:line 12
   at EazyProject.WebForm236.GemLogo(FileUpload fileupload) in D:\a\1\s\EazyProjectCode\EazyProject\O_admin_faktura_setup.aspx.vb:line 270
   at EazyProject.WebForm236.savelogo_Click(Object sender, EventArgs e) in D:\a\1\s\EazyProjectCode\EazyProject\O_admin_faktura_setup.aspx.vb:line 300
   at System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Unable to load library 'libSkiaSharp'.
   at SkiaSharp.LibraryLoader.LoadLocalLibrary[T](String libraryName)
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()

@mattleibow mattleibow marked this as a duplicate and then as not a duplicate of #2385 Feb 28, 2024
@mattleibow
Copy link
Contributor

Is the libSkiaSharp.dll file in the bin folder somewhere? How are you publishing/deploying? Are you able to share a msbuild binlog so I can see why the native binary is not reaching the final output.

If you run the app locally after publishing, does it work?

@romansp
Copy link

romansp commented Feb 28, 2024

@mattleibow We're also seeing this error but when trying out 3.0 preview 2.

It's a browser-wasm app on .Net 8. Loads fine on 2.88.7 and HarfBuzzSharp 7.3.0.1. We don't use Blazor but we do include reference to SkiaSharp.Views.Blazor for InterceptGLObject workaround and that's where it fails to load libSkiaSharp.

Haven't tried publishing yet as we're seeing this error with regular dotnet build.

Didn't want to bother early because it's still a preview. But can create a minimal repro if that's already expected to work properly.

@jakobeazy
Copy link
Author

hi
I was actually using the svg.skia nuget package. Changing to use the svg package solved it for me.

@prashants7718
Copy link

Hi @jakobeazy ,

How you have solved this issue, have you changed package and used another package for svg generation

@jakobeazy
Copy link
Author

Yes, i changed the nuget package from svg.skia to svg.

@mattleibow
Copy link
Contributor

@romansp it should be working since there should be no changes for wasm in 3.x Please attach a repro/sample so I can have a look.

@enghch
Copy link

enghch commented Sep 20, 2024

@mattleibow I have the same issue when trying to run a Wasi Console app that depends on SkiaSharp. It builds the single-file wasm just fine. But when attempting to run, it throws:

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants