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] SKiaSharp on linux can't find liblibSkiaSharp.so #2653

Open
1 task done
aodpi opened this issue Oct 19, 2023 · 17 comments
Open
1 task done

[BUG] SKiaSharp on linux can't find liblibSkiaSharp.so #2653

aodpi opened this issue Oct 19, 2023 · 17 comments
Labels

Comments

@aodpi
Copy link

aodpi commented Oct 19, 2023

Description

I'm trying to use SkiaSharp on .net core 7.0 to validate an image size. The app is running on a docker container on alpine linux.

I've installed the package SkiaSharp.NativeAssets.Linux in my project. After building the libSkiaSharp.so is present in the folder runtimtes/linux-musl-x64/native/ so it should work fine. But for some reason .net is try to load a file called liblibSkiaSharp.so in that folder. Is it a naming issue or something, where does the second lib word come from ?

The version of SkiaSharp I'm using is: 2.88.6

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:

using var imageStream = file.OpenReadStream();
using var bitmap = SKBitmap.Decode(imageStream);

if (bitmap == null)
{
    return new ValidationResult("The image could not be decoded.");
}

var size = bitmap.Info.Size;

if (size.Width > 512 || size.Height > 512)
{
    return new ValidationResult("The image dimensions are too large.");
}

Expected Behavior

The image should be loaded successfully.

Actual Behavior

Trying to decode an image throws an exception

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

Linux

Platform / Operating System Version

No response

Devices

No response

Relevant Screenshots

No response

Relevant Log Output

Error loading shared library libSkiaSharp: No such file or directory
Error loading shared library /app/runtimes/linux-musl-x64/native/liblibSkiaSharp: No such file or directory
Error loading shared library /usr/share/dotnet/shared/Microsoft.NETCore.App/7.0.12/liblibSkiaSharp: No such file or directory
Error loading shared library /app/liblibSkiaSharp: No such file or directory
Error loading shared library liblibSkiaSharp: No such file or directory

   at SkiaSharp.SkiaApi.sk_managedstream_set_procs(SKManagedStreamDelegates procs)
   at SkiaSharp.SKAbstractManagedStream..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKAbstractManagedStream..ctor(Boolean owns)
   at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)
   at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)
   at SkiaSharp.SKCodec.Create(Stream stream, SKCodecResult& result)
   at SkiaSharp.SKCodec.Create(Stream stream)
   at SkiaSharp.SKBitmap.Decode(Stream stream)

Code of Conduct

  • I agree to follow this project's Code of Conduct
@aodpi aodpi added the type/bug label Oct 19, 2023
@hsellentin
Copy link

hsellentin commented Nov 9, 2023

I'm experiencing this too on linux app service on Azure

Edit: issue came down to user error. SkiaSharp.NativeAssets.Linux.NoDependencies version 2.88.6, along with the base skiasharp 2.88.6 worked fine for me.

@jhariel8
Copy link

jhariel8 commented Nov 20, 2023

I seem to be having a similar issue. We are running our application in Azure Kubernetes Service on a Linux container.

Whenever we get images to start processing them, we get this exception:

System.TypeInitializationException: The type initializer for 'SkiaSharp.SKAbstractManagedStream' threw an exception.\nInner Exception: System.TypeInitializationException: Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibSkiaSharp: cannot open shared object file: No such file or directory\n at SkiaSharp.SKAbstractManagedStream..ctor(Boolean owns)\n at SkiaSharp.SKManagedStream..ctor(Stream managedStream, Boolean disposeManagedStream)\n at SkiaSharp.SKCodec.WrapManagedStream(Stream stream)\n at...

SkiaSharp.NativeAssets.Linux.NoDependencies is installed on this project. We did see a similar issue a while back and installing that package seemed to alleviate it. But we are fully up-to-date on SkiaSharp and the SkiaSharp.NativeAssets package (both are 2.88.6) and are seeing this issue suddenly pop up again.

I've tried several remedies that I've seen in the Issues here, including

  • adding "-r linux-x64" to the dotnet publish step in the Dockerfile
  • removing the SkiaSharp package and only installing the NativeAssets package
  • Adding the SkiaSharp.NativeAssets.Linux (with dependencies) instead of the NoDependencies version

Nothing so far as worked.

@jhariel8
Copy link

@aodpi Have you found any workarounds for this since the OP?

@aodpi
Copy link
Author

aodpi commented Nov 21, 2023

@aodpi Have you found any workarounds for this since the OP?

I haven't found any workarounds, I ended up not using Skiasharp anymore

@narojay
Copy link

narojay commented Dec 20, 2023

@aodpi Have you found any workarounds for this since the OP?

I haven't found any workarounds, I ended up not using Skiasharp anymore

same bug

@MarkWilds
Copy link

I also keep getting this. nothing works

@mattleibow
Copy link
Contributor

mattleibow commented Feb 28, 2024

Does things start to work if you use the SkiaSharp.NativeAssets.Linux.NoDependencies package? The No dependencies package is built without advanced font features to remove a dependency.

SkiaSharp depends on Font Config, so make sure you either use "NoDependencies" or you install the fontconfig package using the Linux package manager - apt/apt-get/apk

@hjrb
Copy link

hjrb commented Apr 3, 2024

sudo apt install fontconfig - no difference. Same error message.

@hjrb
Copy link

hjrb commented Apr 3, 2024

see https://curia.me/develop-graphical-linux-apps-with-avalonia-ui/
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y
sudo apt install libice6
sudo apt install libsm6
sudo apt install libfontconfig1
This is to make a Avalonia based .NET 8 run. You might need less. But who cares about some bits...

@jhariel8
Copy link

Does things start to work if you use the SkiaSharp.NativeAssets.Linux.NoDependencies package? The No dependencies package is built without advanced font features to remove a dependency.

SkiaSharp depends on Font Config, so make sure you either use "NoDependencies" or you install the fontconfig package using the Linux package manager - apt/apt-get/apk

That's the package we are using but it did not fix this issue.

@alanrose
Copy link

@jhariel8 I also was running under a linux build with this issue. If it helps my fix was to uninstall all Skiasharp packages and only install the NoDependencies package

@Saganeiro
Copy link

I have a same issue on Azure pipeline with Docker.:

Error Message:
System.DllNotFoundException : Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library liblibSkiaSharp: No such file or directory

How to resolve that? Switching SkiaSharp / SkiaSharp.NativeAssets.Linux.NoDependencies / SkiaSharp.NativeAssets.Linux didn't help.

@moemura
Copy link

moemura commented Jul 12, 2024

@jhariel8 I also was running under a linux build with this issue. If it helps my fix was to uninstall all Skiasharp packages and only install the NoDependencies package

this works for Syncfusion libs, thanks

@moemura
Copy link

moemura commented Jul 12, 2024

I have a same issue on Azure pipeline with Docker.:

Error Message: System.DllNotFoundException : Unable to load shared library 'libSkiaSharp' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Error loading shared library liblibSkiaSharp: No such file or directory

How to resolve that? Switching SkiaSharp / SkiaSharp.NativeAssets.Linux.NoDependencies / SkiaSharp.NativeAssets.Linux didn't help.

can you manually copy the .so files?

@Ragurajan21
Copy link

I am also using skiasharp 2.88.8 in .net 8 and running it Linux container getting the same issue , is there any workaround for this issue

@foxy0669
Copy link

foxy0669 commented Sep 5, 2024

@Ragurajan21 I've just had the same problem. It was working fine on windows but running with in a docker container I had the same problem. I installed SkiaSharp.NativeAssets.Linux 2.88.8 but that made no difference.

The fix for me was to install libfontconfig1

docker exec -it --user root bash
apt-get update
apt-get install libfontconfig1

I just need to add that into my Dockerfile for when I build the container

@JamestsaiTW
Copy link

JamestsaiTW commented Sep 15, 2024

Hi guys,
I build and run an AvaloniaUI app by WSL (Ubuntu). Similar problem occurred and got the following expections:

First:

System.TypeInitializationException: 'The type initializer for 'SkiaSharp.SKImageInfo' threw an exception.'

InnerException:
System.DllNotFoundException: Unable to load shared library 'libSkiaSharp' 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:  libfontconfig.so.1: cannot open shared object file: No such file or directory...

Second:

System.DllNotFoundException: 'Unable to load shared library 'libICE.so.6' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. 

Third:

System.DllNotFoundException: 'Unable to load shared library 'libSM.so.6' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace

The fix for me was to install libfontconfig1, libice6, and libsm6 to my WSL (Ubuntu).

sudo apt install libfontconfig1
sudo apt install libice6
sudo apt install libsm6

Hope it will help you guys.

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