Repository navigation
Description
Current behavior
On Skia Android with the Vulkan render view, a Debug build can abort on the render thread:
---- DEBUG ASSERTION FAILED ----
details.renderAction is null
at Uno.UI.Dispatching.NativeDispatcher.EnqueueRender(Object compositionTarget, Action handler)
at Microsoft.UI.Xaml.Media.CompositionTarget.OnNativePlatformFrameRequested(...)
at Uno.UI.Runtime.Android.UnoVulkanView.RenderFrame()
at Uno.UI.Runtime.Android.UnoVulkanView.RenderLoop(Object state)
Fatal signal 6 (SIGABRT) ... (UnoVulkanRender)
It is intermittent (seen 3 times in roughly 10-15 launches), and always on the first launch after an install (cold start). Each time it was preceded by:
CompositionTarget#...: a render request has been outstanding for 2290-4015ms with no frame from the host ... asking again.- Choreographer
Skipped 103-261 frames(UI thread busy).
The following launches were fine. It happened on a heavy page and on a trivial one (Buttons/Button_Events), so a slow cold start is enough.
Expected behavior
No crash. A second render request that arrives while one is still queued should coalesce. The code after the assert already does that: it replaces the handler and does not enqueue again.
How to reproduce it
Not deterministic, and I did not build a minimal repro. This was confirmed by code inspection plus the logcat above.
- Build the Skia Android SamplesApp (or any Skia Android app) in Debug, on an API 35 x86_64 emulator with Vulkan.
- Run
dotnet build -t:Installand launch right after the install (cold dex, UI thread slow for a few seconds). - Repeat launches until the abort shows up in logcat.
Workaround
Use a Release build (Debug.Assert is compiled out), or set FeatureConfiguration.Rendering.UseVulkanOnSkiaAndroid = false to avoid the Vulkan view.
Works on UWP/WinUI
N/A (Uno internal render scheduling)
Environment
Uno Platform master @ 951b7b464b8 (the same code was present at the merge base of recent PRs), Debug, net10.0-android, Skia renderer, API 35 x86_64 emulator with Vulkan.
Affected platforms
Skia Android (Vulkan render view), Debug builds only.
Anything else we need to know?
Root cause (source-backed):
- The render thread calls
OnNativePlatformFrameRequestedevery frame (fromUnoVulkanView.RenderFrame). It callsNativeDispatcher.Main.EnqueueRenderonly when_shouldEnqueueRenderOnNextNativePlatformFrameRequestedswaps fromtruetofalse. - The flag is normally set back to
trueonly byEnqueueRenderCallback, i.e. after the UI thread has run the queued render action. - The stall recovery in
IsRenderRequestStalled(called fromRequestNewFrameon the UI thread) also sets the flag totrueafter a request has been outstanding for a while. That is exactly the "asking again" warning in the log. - If the UI thread is busy, the render action queued by the previous frame is still pending when that happens. The next render-thread frame then sees the flag
trueand callsEnqueueRenderagain whiledetails.renderActionis non-null. NativeDispatcher.EnqueueRenderassertsdetails.renderAction is null. The code right below it handles the non-null case correctly (no second_globalCountincrement, just replaces the handler), so the assert is stricter than the real contract. On Android a failedDebug.Assertis aFailFast.
Suggested fix: drop the Debug.Assert in EnqueueRender (or turn it into a trace line), since the stall-recovery path legitimately re-requests while an action is queued. Alternatively, have IsRenderRequestStalled not re-arm the flag while a render action is still pending.
The same pattern may affect the other Android render views (UnoCanvasView, UnoWebGpuView), since they call the same OnNativePlatformFrameRequested; not checked at runtime.
Activity
refactor(composition): Remove the stalled-render recovery
refactor(composition): Remove the stalled-render recovery
refactor(composition): Remove the stalled-render recovery
refactor(composition): Remove the stalled-render recovery
refactor(composition): Remove the stalled-render recovery
refactor(composition): Remove the stalled-render recovery