Closed andrfgs closed 3 years ago
Make sure that you are using matching versions of native libraries and their managed wrappers (SkiaSharp/HarfbuzzSharp)
The native libraries are provided by the nuget packages as well and they are indeed on the same version.
Those are the nuget packages for the native version I use:
SkiaSharp.NativeAssets.Linux 2.80.3-preview.40
HarfBuzzSharp.NativeAssets.Linux 2.6.1.7
Isn't it just this I need to provide?
I've checked yesterday with our default template, Ubuntu 18.04 and Mono 6.12.0.90, seems to work OK (except for the required workaround for SkiaSharp's musl binaries)
OK so I was able to use that demo and it runs fine. My guess Is that perhaps creating the project using its template from Avalonia .Net Core App
and then downgrading from .Net 5 to .Net Framework 4.72 won't work.
Since I'm using Linux and there seems to be no way to build a template of Avalonia for Mono, I simply copy pasted that example project and renamed it to my project name and that works.
The question now is. Is the Avalonia .Net Core App
able/supposed to work in lower .Net versions by simply downgrading the .Net version on the .csproj
file?
Avalonia itself is targeting netstandard2.0
, netcoreapp2.0
and net461
as minimum supported versions of target frameworks. Templates are always targeting the latest stable .NET, but can be downgraded if needed.
We do not, however, support building with legacy SDKs (e. g. MSBuild 4.5 or xbuild from Mono), .NET Core 2.0+ SDK or .NET 5+ SDK are required.
I was using .Net Sdk 5.0 but the template says Avalonia .NET Core App
. I tried downgrading and it was complaining with System.DllNotFoundException: Unable to load library 'libSkiaSharp'
even though the .so files were there, so I tried many things such as LD_PRELOAD
etc.
I finally found out why the examples work and this didn't work. Just as you mentioned in a previous issue, you need to apply that fix to tell SkiaSharp
not to use Musl. I also had to rebuild the project, because for some reason it wasn't linking properly to the correct version. I understand the fix, but still doesn't explain why it wasn't finding the dll file. So I'm guessing I somehow corrupted the bin directory by manually placing the .so
files there.
In short, this is how to get it to work:
1) Generate the project using dotnet new avalonia.app
2) Downgrade the project either by changing the .csproj
file or using an IDE, I personally used Jetbrains Rider
3) Edit the .csproj
file to make Skia not use musl on a Glibc installation, by adding:
<Target Name="SkiaSharpRemoveMusl" BeforeTargets="BeforeBuild">
<ItemGroup>
<Content Remove="@(Content)" Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('%(FullPath)', 'packages.*linux-musl.*so')) " />
</ItemGroup>
</Target>
4) Rebuilding the proj
I'm assuming the original problem was a link error, but that is now fixed. Thanks for all the help as well!
Describe the bug Avalonia segfaults on Linux when using mono. I am using
SkiaSharp
(2.80.3-preview.40) andHarfBuzzSharp
(2.6.1.7) through Nuget along with theirSkiaSharp.NativeAssets.Linux
andHarfBuzzSharp.NativeAssets.Linux
respectively. For some reason, I need to manually place the .so files on thebin
folder, but that's not really an issue. The real issue is Avalonia segfaults upon launch.To Reproduce
/usr/bin/mono-sgen /home/andre/RiderProjects/AvaloniaApp/AvaloniaApp/bin/Debug/net461/AvaloniaApp.exe
Expected behavior The program should launch the Avalonia app.
Native Crash Report Upon running:
/usr/bin/mono-sgen /home/andre/RiderProjects/AvaloniaApp/AvaloniaApp/bin/Debug/net461/AvaloniaApp.exe
The following crash happens:
Desktop (please complete the following information):
Additional context Avalonia works on .Net Core 5 fine, but I guess that is quite unrelated as the build system is completely different. Might this be a bug with the current preview versions?
I can't downgrade it though because Avalonia 10.0 requires SkiaSharp > 80.2, so the 80.2 is incompatible.