Skip to content

[GPU 11/20] Complete WebGPU async errors, mapping, copies and device-loss semantics #33

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 11 of 20.
Depends on: #32.

Outcome

Complete the observable asynchronous behavior needed by Kestrel's GPU tests and reliable WebGPU applications.

Implementation

  • Implement pushErrorScope/popErrorScope with proper nesting, filters, operation association and promise delivery; dispatch GPU uncaptured errors through the correct EventTarget.
  • Implement device.lost, destroy/loss reasons, late callbacks, cancellation and independent-device isolation. Loss must not silently change the canvas API or discard unrelated documents.
  • Implement mapAsync/getMappedRange/unmap/mapped-at-creation behavior, overlapping/out-of-range mapping checks, JS ArrayBuffer lifetime and required detach/invalidation behavior.
  • Implement buffer/texture copies, row/offset alignment and queue.onSubmittedWorkDone with correct ordering and data visibility.
  • Progress backend events and promise resolution when hidden/headless/no RAF; preserve event-loop/microtask ordering.
  • Ensure explicit readback is separately counted from presentation. Never make onSubmittedWorkDone a per-frame compositor wait.
  • Run all nine unchanged Kestrel GPU functional tests through the native runtime and add native-presenter assertions beyond their offscreen checks.

Tests

  • Nested/mismatched scopes, rejected operations, delayed error callbacks and uncaptured-error listeners.
  • Mapping cancellation, unmap/destroy during map, device loss with pending promises, navigation before callback.
  • Non-256-aligned readback dimensions with padded bytesPerRow, mapped pixel correctness and subsequent resource cleanup.
  • Queue writes/copies/submits before completion notification and multi-device isolation.
  • Hidden/headless completion and all nine Kestrel GPU cases, including no fallback masquerading as a pass.

Verification evidence

Attach full Kestrel GPU report (nine tests, actual hardware), mapped pixel assertions, error/loss event traces and resource counters after teardown. Report unavailable hardware separately.

Acceptance

  • All nine supplied GPU tests pass through actual WebScene V8 bindings.
  • Mapping memory and pending promise lifetime remain correct through unmap/destroy/loss.
  • Error scopes/events and queue completion reflect the correct operations.
  • No RAF/UI-thread dependency or routine global GPU wait is introduced.
  • Readback traffic is observable and limited to explicit operations/tests.

Completion requirements

Link the implementation PR, exact test commands, native/runtime/framework revisions and verification artifacts before closing. Follow the epic's architecture and copy/lifetime invariants. Any unavailable mandatory hardware or missing required functionality remains incomplete, not a pass.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions