Avalonia: [OpenGL] Unable to initialize GLX-based rendering

Hi there,

currently im working on an avalonia application using the avalonia template from the apolloX extension. everytime i launch the application i get a message that glx based rendering could not be initialized. is anyone else facing that issue or having an idea what could lead to that behavior?

heres the error:

[OpenGL] Unable to initialize GLX-based rendering: 'System.EntryPointNotFoundException: Unable to find an entry point named 'glXGetProcAddress' in shared library 'libGL.so.1'.
   at Avalonia.X11.Glx.GlxInterface.GlxGetProcAddress(Utf8Buffer buffer)
   at Avalonia.OpenGL.GlInterfaceBase`1.<>c__DisplayClass2_0.<ConvertNative>b__0(String proc) in /_/src/Avalonia.OpenGL/GlInterfaceBase.cs:line 67
   at Avalonia.OpenGL.GlEntryPointAttribute.GetProcAddress(Func`2 getProcAddress) in /_/src/Avalonia.OpenGL/GlEntryPointAttribute.cs:line 40
   at Avalonia.OpenGL.GlInterfaceBase`1..ctor(Func`2 getProcAddress, TContext context) in /_/src/Avalonia.OpenGL/GlInterfaceBase.cs:line 50
   at Avalonia.X11.Glx.GlxDisplay..ctor(X11Info x11, IList`1 probeProfiles) in /_/src/Avalonia.X11/Glx/GlxDisplay.cs:line 20
   at Avalonia.X11.Glx.GlxPlatformOpenGlInterface.TryCreate(X11Info x11, IList`1 glProfiles) in /_/src/Avalonia.X11/Glx/GlxPlatformFeature.cs:line 34'

used hardware:
Colibri IMX8QXP 2GB V1.0D
Iris Carrier Board V2.0
Torizon 6.2.0-build.2

hope anyone can help

best regards
Dominik

after i updated my project to the current version of the avalonia mvvm template the stack changed a bit:

[OpenGL] Unable to initialize GLX-based rendering: 'Avalonia.OpenGL.OpenGlException: Unable to find a suitable GL function for CreateContextAttribsARB
   at Avalonia.OpenGL.GlInterfaceBase`1..ctor(Func`2 getProcAddress, TContext context) in /_/src/Avalonia.OpenGL/GlInterfaceBase.cs:line 58
   at Avalonia.OpenGL.GlInterfaceBase..ctor(Func`2 getProcAddress) in /_/src/Avalonia.OpenGL/GlInterfaceBase.cs:line 11
   at Avalonia.X11.Glx.GlxInterface..ctor() in /_/src/Avalonia.X11/Glx/Glx.cs:line 110
   at Avalonia.X11.Glx.GlxDisplay..ctor(X11Info x11, IList`1 probeProfiles) in /_/src/Avalonia.X11/Glx/GlxDisplay.cs:line 20
   at Avalonia.X11.Glx.GlxPlatformOpenGlInterface.TryCreate(X11Info x11, IList`1 glProfiles) in /_/src/Avalonia.X11/Glx/GlxPlatformFeature.cs:line 34'

Hi @tisis2 !

Could you please share the output of tdx-info (reference: Getting Device Information with Tdx-Info | Toradex Developer Center)?

Also, which exact version of ApolloX are you using?

Does this issue occur with the default template? Or have you made some changes?

Best regards,

hi there,

here is what i got from tdx-info:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.77-6.2.0+git.aa0ff7e3554e #1-TorizonCore SMP PREEMPT Wed Mar 29 15:33:40 UTC 2023
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.0/torizon/decdcdd4a4ca02824cd2e34fae717ba7d1b76df4b86a8881b3f5ff83fa8d25fc/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.2.0-build.2
Hostname:                 colibri-imx8x-07252196
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX8QXP on Colibri Evaluation Board V3
Toradex version:          0038 V1.0D
Serial number:            07252196
Processor arch:           aarch64
------------------------------------------------------------

ApolloX is at v2.0.0

i also tried with the default template project without making any changes:

Starting: "ssh" -T -q -p 2223 -i /home/dog/testprojects/ToradexStartupProject200/.conf/id_rsa -o StrictHostKeyChecking=no -o "UserKnownHostsFile /dev/null" torizon@colibri-imx8x-07252196 "/vsdbg/vsdbg --interpreter=vscode"
-------------------------------------------------------------------
You may only use the Microsoft .NET Core Debugger (vsdbg) with
Visual Studio Code, Visual Studio or Visual Studio for Mac software
to help you develop and test your applications.
-------------------------------------------------------------------
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Private.CoreLib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/ToradexStartupProject200.dll'. Symbols loaded.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.DesktopRuntime.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Controls.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/netstandard.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Base.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.ObjectModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Styling.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Input.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Interactivity.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Layout.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Visuals.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Animation.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.ComponentModel.Primitives.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Collections.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Desktop.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.ReactiveUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.X11.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.InteropServices.RuntimeInformation.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Skia.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.OpenGL.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/System.Reactive.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Threading.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Private.Uri.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.ComponentModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Xml.XDocument.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Private.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Private.Xml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Memory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Text.Encoding.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Threading.Thread.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.InteropServices.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.FreeDesktop.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Tmds.DBus.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Collections.Concurrent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Diagnostics.TraceSource.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
[X11Platform] SMLib/ICELib reported a new error: SESSION_MANAGER environment variable not definedEGL: Warning: No default display support on wayland
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.IO.Compression.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
[OpenGL] Unable to initialize EGL-based rendering: 'Avalonia.OpenGL.OpenGlException: eglGetDisplay failed with error EGL_SUCCESS (0x3000)
   at Avalonia.OpenGL.Egl.EglDisplay.CreateDisplay(EglInterface egl, Int32 platformType, IntPtr platformDisplay, Int32[] attrs) in /_/src/Avalonia.OpenGL/Egl/EglDisplay.cs:line 43
   at Avalonia.OpenGL.Egl.EglDisplay..ctor(EglInterface egl, Boolean supportsSharing, Int32 platformType, IntPtr platformDisplay, Int32[] attrs) in /_/src/Avalonia.OpenGL/Egl/EglDisplay.cs:line 48
   at Avalonia.OpenGL.Egl.EglDisplay..ctor(EglInterface egl, Boolean supportsSharing) in /_/src/Avalonia.OpenGL/Egl/EglDisplay.cs:line 22
   at Avalonia.OpenGL.Egl.EglDisplay..ctor(Boolean supportsSharing) in /_/src/Avalonia.OpenGL/Egl/EglDisplay.cs:line 144
   at Avalonia.OpenGL.Egl.EglDisplay..ctor() in /_/src/Avalonia.OpenGL/Egl/EglDisplay.cs:line 139
   at Avalonia.OpenGL.Egl.EglPlatformOpenGlInterface.<>c.<TryCreate>b__15_0() in /_/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs:line 29
   at Avalonia.OpenGL.Egl.EglPlatformOpenGlInterface.TryCreate(Func`1 displayFactory) in /_/src/Avalonia.OpenGL/Egl/EglPlatformOpenGlInterface.cs:line 34'
Loaded '/home/torizon/app/SkiaSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Splat.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/ReactiveUI.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.ComponentModel.TypeConverter.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
LogHost: Initializing to normal mode (.cctor)
Loaded '/home/torizon/app/Avalonia.Markup.Xaml.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Themes.Fluent.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Runtime.CompilerServices.Unsafe.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Markup.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Threading.Tasks.Extensions.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/Avalonia.Diagnostics.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/dotnet/shared/Microsoft.NETCore.App/6.0.5/System.Buffers.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Loaded '/home/torizon/app/HarfBuzzSharp.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

my project differ in a way that i wanted to get my avalonia application separated from the toradex startup confiugrations. so i splitted that into two different project that are referenced

Hi @tisis2 !

Sorry for the delay.

Unfortunately, there is no GLX support.

Have you tried to use the dotnetAvaloniaFrameBuffer (DRM) template instead?

Best regards,

hi @henrique.tx

according to the datasheet, there is opengl support on the module we use:

yes, we tried the framebuffer template in the past but there we were not able to get the touch input to work and with the other template it was working. that was the reason for us to work with that template. and on the other hand, we wanted to take advantage of the 2d acceleration.

best regards
Dominik

Hi @tisis2,

even though there is OpenGL, there is not GLX support in the drivers. Even the tests were removed some time ago piglit: Add PACKAGECONFIG for glx and opencl · Freescale/meta-freescale@1564853 · GitHub.

Moving forward, NXP has dropped support for X[1] in their latest BSP, and that change has reflected in the TorizonCore images (more information: Continued support for X11 and general road map for minimals? - #2 by rafael.tx).

Avalonia has a WIP for supporting Wayland backends, and some members of our team have been in touch with them raising this concern.

were not able to get the touch input to work and with the other template it was working

My recommendation would be to get the input to work and use that template instead. Feel free to reach out about this issue if you haven’t already.

Regards,

[1] XWayland is limited but still available.

1 Like

hi,

thanks for your answer. i also tried to not use glx and use egl instead like it is set up in the avalonia template, but this will also result in init exceptions stated above. so it is not just about glx at this point if i understand it right.

according to 2D/3D Graphics Acceleration (GPU) | Toradex Developer Center i would have expected it to work since the template uses the weston container which is a wayland compositor. so in my understanding wayland should be used?

i also modified my project to use linux framebuffer. it was working in general but it seemed to be even less performant than running the application on weston without a working graphics acceleration.
i am also confused now since i saw the post here (https://community.nxp.com/t5/i-MX-Processors/X11-support-for-iMX8-and-iMX8M/td-p/822981) where the tech support of nxp also stated frame buffer as not supported

best regards
Dominik

Hi @tisis2 ,

sorry for the delay.
We’re working on that, I’ll come back to you as soon as possible.

Best Regards
Kevin

1 Like

Hey @tisis2

unfortunately the problem is not on our Wayland side. Avalonia does not support Wayland backend for now😓: Our own backends for X11/Wayland · Issue #1243 · AvaloniaUI/Avalonia · GitHub

So, when using Wayland the true for Avalonia is that you are using xWayland, that does not support OpengGL ES.

On the Avalonia Framebuffer template, there are two ways:

So, make sure you are using DRM mode, if you are not already. And, if you are already using it let me know, because that’s the mode we’ve tested with the best performance, and we have to look into it if you’re having issues.

Best Regards,

1 Like

@matheus.tx and @tisis2
I have to select an open source C#/.NET GUI library or platform for developing a simple GUI application using a touchscreen 10.1’’ or 7’’ and with Todarex’s Verdin SOM i.MX 8M Plus.

This application will only run onto Torizon.

torizon@verdin-imx8mp-15229850:~$ sudo tdx-info
Password:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           5.15.148-6.6.1+git.23a8e831749d #1-TorizonCore SMP PREEMPT Thu Feb 29 20:25:21 UTC 2024
Kernel command line:      root=LABEL=otaroot rootfstype=ext4 quiet logo.nologo vt.global_cursor_default=0 plymouth.ignore-serial-consoles splash fbcon=map:3 ostree=/ostree/boot.1/torizon/f5f0b9e40c1595ab904ce493a792a0b54e17f0dc3ce6832ddb889452bdd13704/0
Distro name:              NAME="TorizonCore"
Distro version:           VERSION_ID=6.6.1-build.14
Distro variant:           VARIANT="Docker"
Hostname:                 verdin-imx8mp-15229850
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Verdin iMX8M Plus WB on Verdin Development Board
Toradex version:          0058 V1.1B
Serial number:            15229850
Processor arch:           aarch64
------------------------------------------------------------
torizon@verdin-imx8mp-15229850:~$

Can you give me some hints because I don’t know which solution is the more stable nowadays.

Is it Avalonia (.NET 8 C# Avalonia GTK MVVM or .NET 8 C# Avalonia Frame Buffer) or is it Uno Platform ( .NET 8 C# Uno Platform 5.x Skia.GTK or .NET 8. C# Uno Platform Frame Buffer) ?

I do not want to face bugs because I have to time left to waste, so your experience and advises will be really appreciated.

Many Thanks.

Sincerely,
Francois.

Hello @flepron,

Thanks for posting the question!

Avalonia (.NET 8 C# Avalonia GTK) with GTK might be more stable and have better community support on Linux-based systems like Torizon. Uno can be more complex to set up and may have a steeper learning curve if you are unfamiliar with UWP and XAML. However, both are equally performant in my opinion. You may want to evaluate quickly using our template applications from the VSCode IDE extension.

1 Like

Dear @rudhi.tx

Thank you for your answer.

So, I have started a brand new Avalonia .NET 8 GTK with Hello Torizon !

And as well I have subscribed to the Avalonia Community on Telegram : Telegram: Contact @Avalonia

I’ve found a developer (Telegram: Contact @drwenz : Markus Wenzl) on Telegram who has designed an impressive UI using Avalonia. He is member of Toradex’s Community as well @DrWenz.

I will try to ask him the right learning path and code samples to develop UI applications for Toradex’s SOM using Avalonia.

If you have further information, @rudhi.tx, on how I can get access to code samples or tutorials about Avalonia for beginners and Torizon , you’ll make my day.

Many thanks again.

I keep in touch with you about what’s going on about this topic. This might interest the community.

Sincerely,
François.

Hello @flepron,

Nice that you found another user successfully running an Avalonia app on a Toradex hardware! Also, thanks for sharing it.

We do not have any tutorials on Avalonia, however I find some sample projects and documentation on the official website of Avalonia. Perhaps, those would be helpful for you:

1 Like

Dear @rudhi.tx

Thank you very much.

You can consider this topic fixed.

Anyway, I will keep you updated if I find something else on this topic since @DrWenz sent me a message on Telegram saying that Avalonia with FrameBuffer or Direct Rendering Mode was really efficient.

Here is his message on the 28th of June, 2024.

Hello Francois, nice to e-meet you :)
I put a looooooot of effort in Avalonia for Embedded Devices, my biggest pain point was the startup time back on old version of AvaloniaUI. But for the current state of Avalonia its a pleasure to work with.

When it comes to embedded devices, especially when you directly render to fb or drm you need to keep a few things in mind.
There is no really a "Window" like on the desktop, means dialogs, notifications, overlays etc needs to be inside a single view.

What will be the usage of your embedded device? :)

I have found out a github repo with an application built using Avalonia, which can run on Windows or Linux, which shows the beautiful UI that you can create. I will try to make it work under Torizon. This might interest @matheus.tx.

The repo is : https://github.com/UXDivers/ambient-weather-demo.git

Here are some screen shots:

Have a good day and thank you.

Sincerely,
François.