AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.72k stars 2.22k forks source link

[LinuxFrameBuffer][RaspberryPi] Could not CreateWindow(): IWindowingPlatform is not registered. #2403

Closed Int32Overflow closed 5 years ago

Int32Overflow commented 5 years ago

Hey,

I'm running a Raspberry Pi with Raspbian Lite. I like to run Avalonia in LinuxFramebuffer-Mode on this Raspberry Pi.

Source: like in this example: https://github.com/AvaloniaUI/Avalonia/blob/master/samples/ControlCatalog.NetCore/Program.cs

 internal class Program
    {
        public static AppBuilder BuildAvaloniaApp()
            => AppBuilder.Configure<App>()
                .UsePlatformDetect()
                .LogToDebug();

        private static void ConsoleSilencer()
        {
            Console.CursorVisible = false;
            while (true)
                Console.ReadKey(true);
        }

        private static void Main(string[] args)
        {
            if (args.Contains("--fbdev"))
            {
                Console.WriteLine(">> Run in Mode: Framebuffer");
                AppBuilder.Configure<App>().InitializeWithLinuxFramebuffer(tl =>
                {
                    tl.Content = new MainWindow();
                    ThreadPool.QueueUserWorkItem(_ => ConsoleSilencer());
                });
            }
            else
                BuildAvaloniaApp().Start<MainWindow>();
        }
    }

Console output:

root@raspberrypi:/tmp/demo# dotnet /tmp/demo/RaspberryPiAvaloniaUI.dll --fbdev
>> Run in Mode: Framebuffer

Unhandled Exception: System.Exception: Could not CreateWindow(): IWindowingPlatform is not registered.
   at Avalonia.Controls.Platform.PlatformManager.CreateWindow()
   at Avalonia.Controls.Window..ctor()
   at RaspberryPiAvaloniaUI.MainWindow..ctor()
   at RaspberryPiAvaloniaUI.Program.<>c.<Main>b__2_0(TopLevel tl)
   at LinuxFramebufferPlatformExtensions.InitializeWithLinuxFramebuffer[T](T builder, Action`1 setup, CancellationToken stop, String fbdev)
   at RaspberryPiAvaloniaUI.Program.Main(String[] args)
Abgebrochen

Installed nuget: grafik

What am I doing wrong?

Gillibald commented 5 years ago

I am not sure if that`s the case here. It seems a window is created before the platform is initialized. Pls leave out the - - fbdev argument and everything should work just fine.

Int32Overflow commented 5 years ago

@Gillibald No that's not the solution, because UsePlatformDetect() detects gtk and not Framebuffer!

danwalmsley commented 5 years ago

I dont think you can call UsePlatformDetect is you are using framebuffer, @kekekeks will know the correct method.

kekekeks commented 5 years ago
       tl.Content = new MainWindow();

Switch it to MainView.

BTW, @grokys , we really need that "overlay" popups that don't depend on the platform compositor. They are needed for platforms like fbdev and WASM.

Int32Overflow commented 5 years ago

@kekekeks You mean to say, you can only display UserControls in the Framebuffer mode and no Windows? That makes sense... I will test it. Thank you A better error message would be very practical in such case ;-)

You're right that popups would be very useful for platforms that don't support windows.

Int32Overflow commented 5 years ago

@kekekeks Unfortunately there is now another mistake on my Raspberry Pi.

Build command: dotnet publish -r linux-arm -f netcoreapp2.1

Files:

root@raspberrypi:/tmp# ls demo/
Avalonia.Animation.dll                    SharpGen.Runtime.dll                            System.IO.Pipes.dll                           System.Runtime.InteropServices.dll
Avalonia.Base.dll                         SkiaSharp.dll                                   System.IO.UnmanagedMemoryStream.dll           System.Runtime.InteropServices.RuntimeInformation.dll
Avalonia.Controls.dll                     sosdocsunix.txt                                 System.Linq.dll                               System.Runtime.InteropServices.WindowsRuntime.dll
Avalonia.DesignerSupport.dll              SOS.NETCore.dll                                 System.Linq.Expressions.dll                   System.Runtime.Loader.dll
Avalonia.Desktop.dll                      System.AppContext.dll                           System.Linq.Parallel.dll                      System.Runtime.Numerics.dll
Avalonia.DesktopRuntime.dll               System.Buffers.dll                              System.Linq.Queryable.dll                     System.Runtime.Serialization.dll
Avalonia.Diagnostics.dll                  System.Collections.Concurrent.dll               System.Memory.dll                             System.Runtime.Serialization.Formatters.dll
Avalonia.Direct2D1.dll                    System.Collections.dll                          System.Native.a                               System.Runtime.Serialization.Json.dll
Avalonia.Gtk3.dll                         System.Collections.Immutable.dll                System.Native.so                              System.Runtime.Serialization.Primitives.dll
Avalonia.Input.dll                        System.Collections.NonGeneric.dll               System.Net.dll                                System.Runtime.Serialization.Xml.dll
Avalonia.Interactivity.dll                System.Collections.Specialized.dll              System.Net.Http.dll                           System.Security.AccessControl.dll
Avalonia.Layout.dll                       System.ComponentModel.Annotations.dll           System.Net.HttpListener.dll                   System.Security.Claims.dll
Avalonia.LinuxFramebuffer.dll             System.ComponentModel.DataAnnotations.dll       System.Net.Http.Native.a                      System.Security.Cryptography.Algorithms.dll
Avalonia.Logging.Serilog.dll              System.ComponentModel.dll                       System.Net.Http.Native.so                     System.Security.Cryptography.Cng.dll
Avalonia.Markup.dll                       System.ComponentModel.EventBasedAsync.dll       System.Net.Mail.dll                           System.Security.Cryptography.Csp.dll
Avalonia.Markup.Xaml.dll                  System.ComponentModel.Primitives.dll            System.Net.NameResolution.dll                 System.Security.Cryptography.Encoding.dll
Avalonia.Native.dll                       System.ComponentModel.TypeConverter.dll         System.Net.NetworkInformation.dll             System.Security.Cryptography.Native.OpenSsl.a
Avalonia.OpenGL.dll                       System.Configuration.dll                        System.Net.Ping.dll                           System.Security.Cryptography.Native.OpenSsl.so
Avalonia.Remote.Protocol.dll              System.Console.dll                              System.Net.Primitives.dll                     System.Security.Cryptography.OpenSsl.dll
Avalonia.Skia.dll                         System.Core.dll                                 System.Net.Requests.dll                       System.Security.Cryptography.Primitives.dll
Avalonia.Styling.dll                      System.Data.Common.dll                          System.Net.Security.dll                       System.Security.Cryptography.X509Certificates.dll
Avalonia.Themes.Default.dll               System.Data.dll                                 System.Net.Security.Native.a                  System.Security.dll
Avalonia.Visuals.dll                      System.Diagnostics.Contracts.dll                System.Net.Security.Native.so                 System.Security.Principal.dll
Avalonia.Win32.dll                        System.Diagnostics.Debug.dll                    System.Net.ServicePoint.dll                   System.Security.Principal.Windows.dll
JetBrains.Annotations.dll                 System.Diagnostics.DiagnosticSource.dll         System.Net.Sockets.dll                        System.Security.SecureString.dll
libclrjit.so                              System.Diagnostics.FileVersionInfo.dll          System.Net.WebClient.dll                      System.ServiceModel.Web.dll
libcoreclr.so                             System.Diagnostics.Process.dll                  System.Net.WebHeaderCollection.dll            System.ServiceProcess.dll
libcoreclrtraceptprovider.so              System.Diagnostics.StackTrace.dll               System.Net.WebProxy.dll                       System.Text.Encoding.dll
libdbgshim.so                             System.Diagnostics.TextWriterTraceListener.dll  System.Net.WebSockets.Client.dll              System.Text.Encoding.Extensions.dll
libhostfxr.so                             System.Diagnostics.Tools.dll                    System.Net.WebSockets.dll                     System.Text.RegularExpressions.dll
libhostpolicy.so                          System.Diagnostics.TraceSource.dll              System.Numerics.dll                           System.Threading.dll
libmscordaccore.so                        System.Diagnostics.Tracing.dll                  System.Numerics.Vectors.dll                   System.Threading.Overlapped.dll
libmscordbi.so                            System.dll                                      System.ObjectModel.dll                        System.Threading.Tasks.Dataflow.dll
libSkiaSharp.so                           System.Drawing.Common.dll                       System.Private.CoreLib.dll                    System.Threading.Tasks.dll
libsosplugin.so                           System.Drawing.dll                              System.Private.DataContractSerialization.dll  System.Threading.Tasks.Extensions.dll
libsos.so                                 System.Drawing.Primitives.dll                   System.Private.Uri.dll                        System.Threading.Tasks.Parallel.dll
Microsoft.CSharp.dll                      System.Dynamic.Runtime.dll                      System.Private.Xml.dll                        System.Threading.Thread.dll
Microsoft.VisualBasic.dll                 System.Globalization.Calendars.dll              System.Private.Xml.Linq.dll                   System.Threading.ThreadPool.dll
Microsoft.Win32.Primitives.dll            System.Globalization.dll                        System.Reactive.dll                           System.Threading.Timer.dll
Microsoft.Win32.Registry.dll              System.Globalization.Extensions.dll             System.Reflection.DispatchProxy.dll           System.Transactions.dll
Microsoft.Win32.SystemEvents.dll          System.Globalization.Native.so                  System.Reflection.dll                         System.Transactions.Local.dll
mscorlib.dll                              System.IO.Compression.Brotli.dll                System.Reflection.Emit.dll                    System.ValueTuple.dll
netstandard.dll                           System.IO.Compression.dll                       System.Reflection.Emit.ILGeneration.dll       System.Web.dll
RaspberryPiAvaloniaUI                     System.IO.Compression.FileSystem.dll            System.Reflection.Emit.Lightweight.dll        System.Web.HttpUtility.dll
RaspberryPiAvaloniaUI.deps.json           System.IO.Compression.Native.a                  System.Reflection.Extensions.dll              System.Windows.dll
RaspberryPiAvaloniaUI.dll                 System.IO.Compression.Native.so                 System.Reflection.Metadata.dll                System.Xml.dll
RaspberryPiAvaloniaUI.pdb                 System.IO.Compression.ZipFile.dll               System.Reflection.Primitives.dll              System.Xml.Linq.dll
RaspberryPiAvaloniaUI.runtimeconfig.json  System.IO.dll                                   System.Reflection.TypeExtensions.dll          System.Xml.ReaderWriter.dll
Serilog.dll                               System.IO.FileSystem.AccessControl.dll          System.Resources.Reader.dll                   System.Xml.Serialization.dll
Serilog.Sinks.Debug.dll                   System.IO.FileSystem.dll                        System.Resources.ResourceManager.dll          System.Xml.XDocument.dll
Serilog.Sinks.Trace.dll                   System.IO.FileSystem.DriveInfo.dll              System.Resources.Writer.dll                   System.Xml.XmlDocument.dll
SharpDX.Direct2D1.dll                     System.IO.FileSystem.Primitives.dll             System.Runtime.CompilerServices.Unsafe.dll    System.Xml.XmlSerializer.dll
SharpDX.Direct3D11.dll                    System.IO.FileSystem.Watcher.dll                System.Runtime.CompilerServices.VisualC.dll   System.Xml.XPath.dll
SharpDX.dll                               System.IO.IsolatedStorage.dll                   System.Runtime.dll                            System.Xml.XPath.XDocument.dll
SharpDX.DXGI.dll                          System.IO.MemoryMappedFiles.dll                 System.Runtime.Extensions.dll                 WindowsBase.dll
SharpGen.Runtime.COM.dll                  System.IO.Pipes.AccessControl.dll               System.Runtime.Handles.dll

And now the error message:

root@raspberrypi:/tmp# dotnet /tmp/demo/RaspberryPiAvaloniaUI.dll --fbdev
>> Run in Mode: Framebuffer

Unhandled Exception: System.TypeInitializationException: The type initializer for 'SkiaSharp.SKImageInfo' threw an exception. ---> 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: liblibSkiaSharp: cannot open shared object file: No such file or directory
   at SkiaSharp.SkiaApi.sk_colortype_get_default_8888()
   at SkiaSharp.SKImageInfo..cctor()
   --- End of inner exception stack trace ---
   at SkiaSharp.SKImageInfo..ctor(Int32 width, Int32 height, SKColorType colorType, SKAlphaType alphaType)
   at Avalonia.Skia.FramebufferRenderTarget.CreateDrawingContext(IVisualBrushRenderer visualBrushRenderer)
   at Avalonia.Rendering.ImmediateRenderer.Paint(Rect rect)
   at Avalonia.Controls.TopLevel.HandlePaint(Rect rect)
   at Avalonia.LinuxFramebuffer.FramebufferToplevelImpl.<Invalidate>b__9_0()
   at Avalonia.Threading.JobRunner.Job.Avalonia.Threading.JobRunner.IJob.Run()
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 priority)
   at Avalonia.Controls.Platform.InternalPlatformThreadingInterface.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Application.Run(ICloseable closable)
   at LinuxFramebufferPlatformExtensions.InitializeWithLinuxFramebuffer[T](T builder, Action`1 setup, CancellationToken stop, String fbdev)
   at RaspberryPiAvaloniaUI.Program.Main(String[] args) in C:\Users\franks\source\repos\Temp\RaspberryPiAvaloniaUi\RaspberryPiAvaloniaUI\Program.cs:line 38
Abgebrochen

dot Net INFO:

root@raspberrypi:/tmp# dotnet --info

Host (useful for support):
  Version: 2.2.3
  Commit:  6b8ad509b6

.NET Core SDKs installed:
  No SDKs were found.

.NET Core runtimes installed:
  Microsoft.NETCore.App 2.2.3 [/opt/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
  https://aka.ms/dotnet-download
kekekeks commented 5 years ago

Avalonia.Skia.Linux.Natives, version 1.68.0.1

Int32Overflow commented 5 years ago

Avalonia.Skia.Linux.Natives, version 1.68.0.1

Same error with this Version grafik

Int32Overflow commented 5 years ago

I found a solution on stackoverflow: https://stackoverflow.com/questions/53693042/dllnotfoundexception-using-skiasharp-1-68-on-linux

with ldd you can find dependencies of a library:

root@raspberrypi:/home/pi# ldd /tmp/demo/libSkiaSharp.so 
        linux-vdso.so.1 (0x7ef84000)
        /usr/lib/arm-linux-gnueabihf/libarmmem.so (0x768e7000)
        libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x768be000)
        libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x768ab000)
        libfontconfig.so.1 => not found
        libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x7682c000)
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x766ed000)
        /lib/ld-linux-armhf.so.3 (0x76ef5000)

As you can see the libfontconfig library is missing. I installed this library with this command: apt-get install libfontconfig1