Repository navigation
Description
Current behavior
When X11SoftwareRenderer is the selected renderer (i.e. Vulkan/OpenGL/EGL initialization all failed and the fallback path in X11XamlRootHost instantiates the software renderer), the app can crash on the very first render with:
Unhandled exception. System.InvalidOperationException: Nullable object must have a value.
at System.Nullable`1.get_Value()
at Uno.WinUI.Runtime.Skia.X11.X11SoftwareRenderer.Flush()
at Uno.WinUI.Runtime.Skia.X11.X11Renderer.Render()
at Uno.WinUI.Runtime.Skia.X11.X11XamlRootHost.RenderLoop()
The root cause is in src/Uno.UI.Runtime.Skia.X11/Rendering/X11SoftwareRenderer.cs:
protected override void Flush()
{
_ = X11Helper.XPutImage(
display: _x11Window.Display,
drawable: _x11Window.Window,
gc: _gc,
image: _xImage!.Value, // <-- throws if _xImage is still null
...);
}_xImage is only initialized inside UpdateSize(int, int), which is called from the lambda passed to CompositionTarget.OnNativePlatformFrameRequested in X11Renderer.Render(). If that lambda is not invoked on the first render pass (e.g. the requested size is 0×0 or the composition target otherwise short-circuits), Flush() still runs unconditionally and immediately throws on _xImage!.Value.
The same code is present on `master` and in our local `Uno.UI.Runtime.Skia.X11` 6.7.0-dev.57 build.
Expected behavior
`Flush()` should be a no-op when `_xImage` (or equivalently `_surface`) has not yet been initialized, just like the GL/Vulkan renderers tolerate being called before they have a backing surface. Falling back to the software renderer should never crash the process — currently it is the last-resort fallback in `X11XamlRootHost`, so when it crashes the app has no further fallback.
How to reproduce it
Anything that takes the renderer-selection path in `X11XamlRootHost` down to `new X11SoftwareRenderer(...)` can trigger this. In our case it was reproduced with a packaged `net9.0-desktop` Uno 6.7.0-dev.36 app on Ubuntu 24.04 (Wayland session, XWayland `DISPLAY=:0`) where the loader could not locate `libGL.so.1` / `libEGL.so.1`, so Vulkan + OpenGL + EGL initialization all failed and the software renderer was chosen. The crash is then 100% reproducible on launch.
A minimal logic-level repro: in any X11 desktop app, force the software path (e.g. by hiding `libGL.so.`, `libEGL.so.`, `libGLX.so.*` from `LD_LIBRARY_PATH` so the GL renderers throw and `X11XamlRootHost` falls through to `_renderer = new X11SoftwareRenderer(...)`). The first frame will throw.
I can put together a zipped minimal repro if helpful, but the issue is visible directly from the source.
Workaround
Make sure the hardware renderers can initialize so the software fallback is never used:
- ensure `libGL.so.1`, `libEGL.so.1`, etc. are reachable via `LD_LIBRARY_PATH` / `ldconfig`
A user-side workaround for the actual software-renderer bug isn't possible since the failure is on the first frame, before any application code gets a chance to intervene.
Suggested fix
Guard `Flush()` (and likewise rework `Dispose()` which is already guarded) so it short-circuits when the renderer hasn't been sized yet:
```csharp
protected override void Flush()
{
if (_xImage is not { } xImage)
{
return;
}
_ = X11Helper.XPutImage(
display: _x11Window.Display,
drawable: _x11Window.Window,
gc: _gc,
image: xImage,
srcx: 0, srcy: 0, destx: 0, desty: 0,
width: (uint)_width, height: (uint)_height);
}
```
Renderer
- Skia
Affected platforms
- Desktop (X11)
Uno.Sdk version
`Uno.Sdk` 6.7.0-dev.36 (also visible in source on `master`); `Uno.WinUI.Runtime.Skia.X11` package version 6.7.0-dev.57.
IDE version
N/A — repro is at the runtime/packaging level, IDE-agnostic.
Anything else we need to know?
Happy to send a PR with the null-guard if it would help.
Activity
HakanL commentedon Jul 27, 2026
I upgraded to Uno.Sdk version v6.6.33 and I'm getting this crash at startup on my Snap deployment, both arm64 and x64. I think it's probably due to the snap restrictions I had in place that limited the application to software rendering (I didn't realize). I rolled back to v6.5.36 and then it started working again. FWIW I have enabled the GL acceleration as well, but depending on hardware it is very possible an enduser may end up with software rendering, so it's not possible for me to use v6.6 until this is backported.
jhanvi03 commentedon Jul 29, 2026
Issue resolved in latest sdk/template.
Verified with:
Templates/SDK: 6.6.42
VS VSIX: 6.6.22
VS Code VSIX: 0.25.3
Rider plugin: 1.10.56
HakanL commentedon Jul 30, 2026
I can't see Uno.Sdk 6.6.42 on Nuget
agneszitte commentedon Jul 31, 2026
@HakanL, @paul-reeves, internal testing is done on our side, and this issue is now in the newly released Uno.Sdk 6.6.42, which includes the fix from #23290.
Please let us know whether everything works as expected on your side or if you notice any other issues with this new version.
HakanL commentedon Jul 31, 2026
Perfect, thank you, I will test!
HakanL commentedon Aug 3, 2026
Confirmed working, thank you!