Skip to content

[GPU 17/20] Implement dedicated-worker GPU APIs and OffscreenCanvas ownership #39

Open

Description

@danwalmsley

Parent epic: #22
Implementation order: 17 of 20.
Depends on: #38.

Outcome

Support WebGPU and WebGL in the standard worker/OffscreenCanvas execution environments needed for full API qualification.

Implementation

  • Implement or complete dedicated Worker infrastructure required by these graphics APIs: script loading, isolate ownership, event loop, postMessage/structured clone, transferables, errors and termination.
  • Expose WebGPU only in the standard supported worker globals. Do not expose or clone GPU objects where the pinned spec does not permit it.
  • Implement OffscreenCanvas creation, context mode identity, transferControlToOffscreen, transferable canvas ownership and placeholder/presentation behavior.
  • Connect worker GPU canvases to native texture leases and the main document's scene without passing live V8 handles across isolates.
  • Complete required OffscreenCanvas export/bitmap transfer behavior using the existing snapshot contract.
  • Keep uploads/commands/completions ordered per device/context; progress workers without the main thread's RAF where appropriate.
  • Handle worker termination/navigation while GPU work, mapping or canvas presentation remains in flight; release transferred resources exactly once.
  • Enable Kestrel's existing I/O Worker path only when the Worker implementation is real, then rerun its file workflows.

Tests

  • Window and dedicated-worker WebGPU/WebGL/OffscreenCanvas WPT/CTS cases.
  • Canvas transfer, sender invalidation, transfer/clone errors, wrong-realm objects and repeated context requests.
  • Worker renders while main thread is busy; correct frame publication, resize and placeholder behavior.
  • Terminate worker with pending map/pipeline/export/submission and delayed compositor completion.
  • Kestrel worker-enabled DXF import/export plus prior synchronous fallback regression.

Verification evidence

Provide isolate/thread ownership diagrams, transfer/lifetime tests, worker-specific conformance denominators and resource counters after repeated terminate/recreate.

Acceptance

  • Required worker globals expose real native graphics behavior.
  • OffscreenCanvas ownership/transfer/export/presentation is spec-correct.
  • No live V8 objects cross isolate boundaries unsafely.
  • Worker teardown cannot leak or invalidate resources still used by the compositor.
  • Main-thread and unchanged Kestrel workflows continue passing.

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