Skip to content

WebGPU on WASM never recovers from a lost device: rendering and RenderTargetBitmap stay dead #25361

Open

Description

@MartinZikmund

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

  1. Run a Skia WebAssembly app with UNO_WEBGPU=1 in Chrome.
  2. Make the GPU device get lost (kill Chrome's GPU process from its task manager, or destroy the imported GPUDevice).
  3. The console logs WebGpuInit: device lost ...; the window stops updating and RenderTargetBitmap.RenderAsync produces 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:
    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;
    (requestDevice once, device.lost.then(...) only logs)
  • Native:
    private static void OnDeviceLost(IntPtr device, WGPUDeviceLostReason reason, WGPUStringView message, IntPtr u1, IntPtr u2)
    => System.Console.Error.WriteLine($"[webgpu] device lost ({reason}): {Text(message)}");
    (OnDeviceLost writes 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

  1. added
    kind/enhancement
    platform/wasm 🌐
    triage/untriaged
    difficulty/challenging 🤯
    on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/skia/composition ✏️difficulty/challenging 🤯kind/enhancementplatform/wasm 🌐triage/untriaged

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions