Repository navigation
Description
Current behavior 🐛
Running the runtime test suite unfiltered against SamplesApp.Skia.Generic on Windows kills the process with an access violation on the finalizer thread, roughly 25 test methods in. No results file is written, so the run produces nothing.
Fatal error. 0xC0000005
at SkiaSharp.SkiaApi.sk_refcnt_safe_unref(IntPtr)
at SkiaSharp.SKObjectExtensions.SafeUnRef(SkiaSharp.ISKReferenceCounted)
at SkiaSharp.SKObject.DisposeNative()
at SkiaSharp.SKNativeObject.Dispose(Boolean)
at SkiaSharp.SKObject.Dispose(Boolean)
at SkiaSharp.SKSurface.Dispose(Boolean)
at SkiaSharp.SKNativeObject.Finalize()
at System.GC.RunFinalizers()
Process exits with SIGSEGV (139).
An SKSurface is being finalized after its native peer has already been freed — a double-free / use-after-free of the surface handle. Because it happens on the finalizer thread it is timing-dependent: two runs of the same build died after 24 and 28 test methods respectively, at different tests.
Expected behavior 🎯
The suite runs to completion and writes its results file.
How to reproduce it (as minimally and precisely as possible) 🔬
dotnet build src/SamplesApp/SamplesApp.Skia.Generic/SamplesApp.Skia.Generic.csproj \
-c Release -f net10.0 -p:UnoFastDevBuild=true -p:UnoTargetFrameworkOverride=net10.0
cd src/SamplesApp/SamplesApp.Skia.Generic/bin/Release/net10.0
dotnet SamplesApp.Skia.Generic.dll --runtime-tests=results.xmlNo UITEST_RUNTIME_TESTS_FILTER — the crash needs the unfiltered run. Filtered runs of up to ~940 tests completed normally in the same environment, so it appears to depend on which tests run together (and on finalizer timing) rather than on any single test.
Environment: Windows 11, .NET 10.0.301, Release, Win32 host.
Workaround 🛠️
Run the suite in filtered shards. CI already shards, which is presumably why this has not blocked it.
Renderer 🎨
- Skia
Affected platforms 📱💻🖥️
Desktop (Windows)
Uno.Sdk version (and other relevant versions) 📦
Reproduced on the feature/breakingchanges branch (SkiaSharp 4.151.1). Not verified against master.
Anything else we need to know? 💬
This was found while validating an unrelated set of rendering performance changes. Because two of those changes altered native path lifetimes, the crash had to be ruled out as a regression rather than assumed: the pre-fix tree crashes identically — same 0xC0000005, same stack, same signal — so it predates that work and is reported here on its own.
SKSurface is created in the platform renderers (Win32WindowWrapper.Rendering.*, the X11 and macOS renderers), RenderTargetBitmap, RetainedLayer and SvgImageSource. Given the failure is an unref of an already-freed handle, the likely shapes are a surface being disposed while a wrapper for the same handle is still alive, or a window teardown racing the finalizer.
Practical impact is on developer workflow rather than apps: it makes a full local runtime-test run impossible, so a whole-suite before/after comparison cannot be done locally and CI has to be the check.
Activity