fix(webgpu): string index arguments and unsupported surface usages - #161
Merged
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) andsetVertexBuffer(render pass, render bundle) passed their index straight to the native binding, which only accepts au32. An index taken from afor...inloop is a string key, so the call threwFailed to convert napi value String into rust type 'u32'. WebIDL converts such an argument to a number, and these methods now do the same withNumber(index).configuremasks usage on desktop hostsconfiguremasked the requestedusageto 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 reports0x13(COPY_SRC | COPY_DST | RENDER_ATTACHMENT), and Pixi asks for0x17(it addsTEXTURE_BINDING). The context stayed unconfigured, andgetCurrentTexture()returnednull. The masking now also runs whenNAPI_HOSTis 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: