Skip to content

Cannot start Avalonia under FreeBSD #6990

@CyberBotX

Description

@CyberBotX

Describe the bug
When trying to use Avalonia under FreeBSD, it cannot start at all. After creating project via the dotnet cli using the MVVM template, the unedited code cannot run because FreeBSD isn't one of the platforms being detected by UsePlatformDetect(). When I change that to UseX11() and add a call to UseSkia(), I instead get an exception because FreeBSD's libc does not have epoll functions in it:

Unhandled exception. System.EntryPointNotFoundException: Unable to find an entry point named 'epoll_create1' in shared library 'libc'.
   at Avalonia.X11.X11PlatformThreading.epoll_create1(Int32 size)
   at Avalonia.X11.X11PlatformThreading..ctor(AvaloniaX11Platform platform) in /_/src/Avalonia.X11/X11PlatformThreading.cs:line 121
   at Avalonia.X11.AvaloniaX11Platform.Initialize(X11PlatformOptions options) in /_/src/Avalonia.X11/X11Platform.cs:line 71
   at Avalonia.AvaloniaX11PlatformExtensions.<>c__0`1.<UseX11>b__0_0() in /_/src/Avalonia.X11/X11Platform.cs:line 266
   at Avalonia.Controls.AppBuilderBase`1.Setup() in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 303
   at Avalonia.Controls.AppBuilderBase`1.SetupWithLifetime(IApplicationLifetime lifetime) in /_/src/Avalonia.Controls/AppBuilderBase.cs:line 179
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime[T](T builder, String[] args, ShutdownMode shutdownMode) in /_/src/Avalonia.Controls/ApplicationLifetimes/ClassicDesktopStyleApplicationLifetime.cs:line 174
   at MyProject.Program.Main(String[] args) in /MyProject/Program.cs:line 21

I cannot get around this currently because I do not see any way with C#'s P/Invoke to override libraries on a per-method basis (I only know of how to use NativeLibrary.SetDllImportResolver for doing so on a per-library basis, which won't work here).

FreeBSD does have epoll functions in the form of a shim over its kqueue functions, namely the port devel/libepoll-shim from https://github.com/jiixyj/epoll-shim, so Avalonia is either going to need a way to specify a way to use kqueue instead of epoll or a way to use libepoll-shim.

To Reproduce
Steps to reproduce the behavior:

  1. Create a new application using the MVVM template.
  2. Change UsePlatformDetect() to UseX11() and add call to UseSkia().
  3. Try to run, get the exception.

Expected behavior
Being able to run even a sample Avalonia application under FreeBSD.

Desktop (please complete the following information):

  • OS: FreeBSD 13.0
  • Avalonia: 0.10.10
  • .NET 6

Additional context
I am using the build of .NET 6 for FreeBSD from https://github.com/Servarr/dotnet-bsd/releases as there is no version of .NET 6 from Microsoft themselves for FreeBSD.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions