Skip to content

Tracking issue: synchronous exceptions in JS API #225

@kainino0x

Description

@kainino0x

I'll attempt to make a complete list of entrypoints that have synchronous exceptions in the JS API:

  • All cases where you try to use a feature that's not enabled on the device that would throw a TypeError on a browser that hasn't implemented the feature at all (see spec)
    • Using an enum value introduced by the feature (e.g. query type "timestamp")
    • Calling a method introduced by the feature (e.g. writeTimestamp)
  • getMappedRange: not mapped; not aligned; out of range; overlaps (Synchronous validation in getMappedRange #64)
  • createBuffer with mappedAtCreation (OOM-ish conditions) (Signaling allocation failure for buffers with mapAtCreation==true #57)
  • external image stuff (copyExternalImageToTexture/importExternalTexture) (not in C API yet, ExternalTexture in WASM #232):
    • "origin-clean" and "check the usability" of external image sources
    • copyExternalImageToTexture source image size check (can be checked in the bindings beforehand so it’s possible to know what the error is, except maybe for HTMLVideoElement because it’s weird and frames advance in the background)
  • writeBuffer: size alignment. Maybe this should be a validation error in the upstream spec?
  • getCurrentTexture: not configured. See proposal: swapchain & presentation rework #197, maybe we need an extra GetCurrentTextureStatus for this?
  • Things that can't happen from C
    • Invalid extent/origin/color arrays
    • Errors about the size of a source BufferSource in writeBuffer/writeTexture/setBindGroup
  • (EDIT 2024-10-18) Invalid formats for configure() - this was recently moved from device timeline to content timeline in the JS spec.

One approach we've been taking for some entrypoints is to say "return a generic error code, with implementation-defined logging" (eventually we're likely to make it well-defined, with a log callback on the instance):

Metadata

Metadata

Assignees

No one assigned

    Labels

    errorsError reportinghas resolutionIssue is resolved, just needs to be donewasmIssues with WebAssembly targets

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions