Skip to content

fix(webgpu): string index arguments and unsupported surface usages - #161

Merged
triniwiz merged 2 commits into
v3-v8from
fix/webgpu-index-arguments
Sep 28, 2026
Merged

triniwiz merged 2 commits into
v3-v8from
fix/webgpu-index-arguments

Conversation

@triniwiz

@triniwiz triniwiz commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Two fixes found running PixiJS v8's WebGPU renderer on Windows (@nativescript/canvas-pixi). With both, it renders; before, it failed at startup.

Index arguments are converted to numbers

setBindGroup (render pass, compute pass, render bundle) and setVertexBuffer (render pass, render bundle) passed their index straight to the native binding, which only accepts a u32. An index taken from a for...in loop is a string key, so the call threw Failed to convert napi value String into rust type 'u32'. WebIDL converts such an argument to a number, and these methods now do the same with Number(index).

configure masks usage on desktop hosts

configure masked the requested usage to the surface's supported usages only on Apple. A Node-API host's surface can support less than what gets requested. On Windows the DirectX 12 swapchain reports 0x13 (COPY_SRC | COPY_DST | RENDER_ATTACHMENT), and Pixi asks for 0x17 (it adds TEXTURE_BINDING). The context stayed unconfigured, and getCurrentTexture() returned null. The masking now also runs when NAPI_HOST is set. Android keeps its current behavior.

Testing

Tested on Windows x64 with 3.0.0-alpha.16 plus these changes in a NativeScript-Vue app:

  • PixiJS on WebGPU: 300 sprites at ~70 fps, started directly on WebGPU.
  • Existing WebGPU demo: a WGSL compute-shader boids demo still runs.

setBindGroup and setVertexBuffer passed their index straight to the
native binding, which only takes a u32, so an index from a for...in loop
(a string key) failed with "Failed to convert napi value String into
rust type u32". WebIDL converts it to a number; so do these now.
configure only masked the requested usage to the surface's supported
usages on Apple. A Node-API host's swapchain (a DirectX 12 one on
Windows) has no TEXTURE_BINDING, so asking for it left the context
unconfigured and getCurrentTexture() returned null.
@coderabbitai

coderabbitai Bot commented Sep 28, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: c53d5e0f-8d55-4b3d-abf1-d111a30b84f2

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@triniwiz
triniwiz merged commit 9ae1a07 into v3-v8 Sep 28, 2026
12 of 19 checks passed
triniwiz added a commit that referenced this pull request Sep 28, 2026
)

* fix(webgpu): convert index arguments to numbers

setBindGroup and setVertexBuffer passed their index straight to the
native binding, which only takes a u32, so an index from a for...in loop
(a string key) failed with "Failed to convert napi value String into
rust type u32". WebIDL converts it to a number; so do these now.

* fix(webgpu): mask configure usage to the surface's on desktop hosts

configure only masked the requested usage to the surface's supported
usages on Apple. A Node-API host's swapchain (a DirectX 12 one on
Windows) has no TEXTURE_BINDING, so asking for it left the context
unconfigured and getCurrentTexture() returned null.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant