Repository navigation
Description
Current behavior
When the WebGPU device is lost (for example the browser's GPU process is restarted), Uno only logs the loss and keeps using the dead device. Nothing re-requests an adapter/device or rebuilds the GPU resources, so rendering stays dead until the page is reloaded.
Observed in the console after a Chrome GPU process crash:
WebGpuInit: device lost (unknown): A valid external Instance reference no longer exists.
Failed to render element to bitmap. AbortError: Failed to execute 'mapAsync' on 'GPUBuffer': A valid external Instance reference no longer exists.
After that every RenderTargetBitmap.RenderAsync leaves PixelWidth/PixelHeight at 0.
Expected behavior
After a device loss the WebGPU backend should re-request the device, rebuild its GPU resources and repaint, so the app keeps rendering without a reload. At minimum the loss should be surfaced to the app instead of silently failing every later GPU call.
How to reproduce it
- Run a Skia WebAssembly app with
UNO_WEBGPU=1in Chrome. - Make the GPU device get lost (kill Chrome's GPU process from its task manager, or destroy the imported
GPUDevice). - The console logs
WebGpuInit: device lost ...; the window stops updating andRenderTargetBitmap.RenderAsyncproduces 0x0 bitmaps.
The missing recovery is confirmed by code inspection of the handlers below. The runtime symptoms were observed on CI after a Chrome GPU-process crash (see #25210); steps 2-3 were not re-run manually.
Workaround
Reload the page.
Works on UWP/WinUI
N/A (DirectX apps handle device removal themselves).
Environment
Skia WebAssembly with WebGPU (Uno.UI.Composition.WebGpu), master @ 0599dad.
Anything else
Root cause: both device-lost handlers only log.
- TS: (
uno/src/Uno.UI.Composition.WebGpu/ts/Runtime/WebGpuInit.ts
Lines 48 to 61 in 0599dad
const device = await adapter.requestDevice({ requiredFeatures } as any); if (!device) { console.error("WebGpuInit: adapter.requestDevice returned null"); return 0; } // A lost device otherwise only shows up later as every async operation aborting, with no reason given. device.lost.then((info: any) => console.error("WebGpuInit: device lost (" + info.reason + "): " + info.message)); device.addEventListener("uncapturederror", (e: any) => console.error("WebGpuInit: uncaptured error: " + e.error?.message)); const module = (window as any).Module; if (!module || typeof module.unoWebGpuImportDevice !== "function") { console.error("WebGpuInit: Module.unoWebGpuImportDevice is missing (emdawn __postset patch not applied?)"); return 0; } const devicePtr = module.unoWebGpuImportDevice(device, instancePtr) >>> 0; requestDeviceonce,device.lost.then(...)only logs) - Native: (
uno/src/Uno.UI.Composition.WebGpu.Init/WebGpuInit.Core.cs
Lines 334 to 335 in 0599dad
private static void OnDeviceLost(IntPtr device, WGPUDeviceLostReason reason, WGPUStringView message, IntPtr u1, IntPtr u2) => System.Console.Error.WriteLine($"[webgpu] device lost ({reason}): {Text(message)}"); OnDeviceLostwrites to the console)
Recovery would need: re-request the device, create a new drawing factory and re-register it, invalidate retained recordings, recreate textures (composition surfaces keep no CPU copy today), recreate the per-window surface context and force full damage. Rough estimate: multiple days.
Related: #25210 is the CI symptom of the same GPU-process crash. This issue tracks the missing recovery itself.
Activity