-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Avalonia on Raspbian #1072
Comments
You need to either use Mono as your runtime and our old GTK# backend or somehow obtain an ARM build of libSkiaSharp. |
Is the GTK# back end you speak of no longer maintained? |
@kekekeks I do not understand why you use GTK? Why not use OPENGL? |
You need something to create windows to render on, you know |
Hi, There are other things to consider, like handling inputs, to have a fully working solution, but at least, displaying things can be a good start. |
There is no MIT (or compatible) licensed OpenVG library that meets our requirements. The one that had been shipped with MESA was removed two years ago. And the only reliable and feature-rich library that can render 2D graphics on top of OpenGL is Skia. Regarding X. /dev/fb0 have been broken for years, so the only way to support proper rendering (i. e. without tearing) is to use DRI/DRM/KMS infrastructure, which was not that stable on Raspberry Pi last time I've checked. |
It is possible to call opengl functions directly, and it works nice. I have also used Qt directly on the raspberry pi without X installed. It uses direct opengl calls also. |
Ask @mterwoord, he had some success in compiling |
I had things working with .net core 2.0 and GTK (not sure 2 or 3) and a self-built libskia. See https://github.com/terwoord/skiasharp-raspberry for a buildscript. Improvements are welcome. :) |
I used @mterwoord 's build script to build a libskia. My Avalonia app contains nothing more than a main window with a grid with two TextBlocks in it. When I try to run it on my Raspberry PI with Raspbian, the main window gets displayed but without any content. When I drag the window around it looks like it crashed. The terminal output does not show any errors though: Any idea what could be wrong or where I could look for more information to diagnose what went wrong? |
After a few more tests with two different Raspberry PIs, I noticed a difference between Raspbian and Linux Mate:
Any idea why text drawing could fail on Raspbian? @kekekeks you mentioned /dev/fb0 with libSkiaSharp. Can you tell me what this is about and how I could use it? (BTW, if anyone is willing to do tests on a Raspberry, I would enjoy to provide one. Remote access via SSH, Teamviewer, XRDP would be possible. I could install either Linux Mate or Raspbian) |
I'm using yocto to build my own linux distribution, and had issues with a different font to be used. |
@mterwoord You are right. If I set the font of my window explicitly to Courier or the default font of Raspbian (Piboto light) all the text is displayed. I am not Linux expert enough to diagnose this any further so I will stick with this solution for now. |
The next problem on Raspbian is that image scaling does not work like mentioned in #1486 . By setting Maybe someone can investigate this problem. I'm not deep enough in this topic to test a later version of libSkiaSharp than 1.57.1 from May 2017 used in mterwoord's build script. |
I can reproduce the issue reported by @nicolasr75 where no text is displayed on Raspian. I am also seeing incorrect colours - my test app is supposed to display rectangles with green, orange and red backgrounds. This works on Windows, however on Raspian the colours rendered are green, light blue and dark blue. I use a converter to bind the switch (status) {
case Status.OK:
return Brushes.Green;
case Status.Warning:
return Brushes.Orange;
case Status.Failure:
return Brushes.Red;
default:
throw new InvalidOperationException();
} |
Is there some reliable way to reproduce the issue in QEMU? We hack the hardware to repro, unfortunately. |
I would be happy to try and find the minimum C# / Avalonia repro for these two issues. I'm not familiar with QEMU though, and from a quick search it seems like getting Raspian running under QEMU is a bit involved (custom kernels etc). If anyone has a prebuilt environment or scripted setup, that would be much appreciated. |
I was able to resolve @nicolasr75 missing text issue by installing the Microsoft font pack :)
Looks like the default font in Avalonia is one of the Microsoft ones? |
@kekekeks - @mattleibow mentioned that this is probably due to the Red / Blue channels being swapped. The SkiaSharp GTK widget swaps these channels for BGRA images. https://github.com/mono/SkiaSharp/blob/master/source/SkiaSharp.Views/SkiaSharp.Views.Gtk/SKWidget.cs#L44 I swapped the B/R channels on the brushes in my converter: private static readonly SolidColorBrush PiGreen = new SolidColorBrush(new Color(
Brushes.Green.Color.A,
Brushes.Green.Color.B,
Brushes.Green.Color.G,
Brushes.Green.Color.R));
private static readonly SolidColorBrush PiOrange = new SolidColorBrush(new Color(
Brushes.Orange.Color.A,
Brushes.Orange.Color.B,
Brushes.Orange.Color.G,
Brushes.Orange.Color.R));
private static readonly SolidColorBrush PiRed = new SolidColorBrush(new Color(
Brushes.Red.Color.A,
Brushes.Red.Color.B,
Brushes.Red.Color.G,
Brushes.Red.Color.R));
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
Status status = (Status)value;
switch (status) {
case Status.OK:
return PiGreen;
case Status.Warning:
return PiOrange;
case Status.Failure:
return PiRed;
default:
throw new InvalidOperationException();
}
} My application works as expected on Raspian with the new brushes (at the expense of Windows compatibility): Is this perhaps an issue with how Avalonia uses GTK / Skia rather than being specific to the Raspberry Pi? |
We probably need to somehow detect the pixel format here: |
If you have a look at what I do with the swapping of the colors for GTK#, I check the platform color format first. You could write a utility function that swaps only on some platforms. You don't need to che k the actual platform, just the platform color that skia reports. |
It seems that GTK selects different X11 visual depending on the platform. I think it should be fixed after we switch from GTK to X11 backend. For now we could add pixel format override option to GtkOptions. |
I rebuilt @kekekeks - do you know if there will be a new set of Avalonia Nuget packages (at least Edit: Updated all Avalonia DLLs to |
Quick summary for those coming in cold (Avalonia 0.8.0):
The above worked for me, although I haven't tested the image stretching issue. |
Is Avalonia compatible raspbian yet? I would assume it would be in theory has it would just need to bind to a gtk build that was built for the pi correct? Has this been tested? Or is there work going on in this area?
Sorry if this is the wrong place for this question. I did not know here else to ask.
The text was updated successfully, but these errors were encountered: