Skip to content

library_webgpu.js shim doesn't seem to support closure pass #20415

Closed as not planned
@floooh

Description

@floooh

emsdk version 3.1.46

Building and running webgpu samples with webgpu.h works fine without the closure pass, but when trying to enable closure with the linker option --closure 1, linking appears to work, but when running I get the following errors on the browser js console:

Uncaught (in promise) TypeError: Failed to execute 'configure' on 'GPUCanvasContext': Failed to read the 'format' property from 'GPUCanvasConfiguration': Required member is undefined.
    at Da (triangle-sapp.js:54:9)
    at triangle-sapp.wasm:0x1165
    at triangle-sapp.wasm:0x1b7b
    at triangle-sapp.js:42:369
    at mc (triangle-sapp.js:27:301)
    at triangle-sapp.js:42:252
onerror: Uncaught TypeError: Failed to execute 'configure' on 'GPUCanvasContext': Failed to read the 'format' property from 'GPUCanvasConfiguration': Required member is undefined.

triangle-sapp.js:54 Uncaught TypeError: Failed to execute 'configure' on 'GPUCanvasContext': Failed to read the 'format' property from 'GPUCanvasConfiguration': Required member is undefined.
    at Da (triangle-sapp.js:54:9)
    at triangle-sapp.wasm:0x1165
    at triangle-sapp.wasm:0x3269
    at Object.lb (triangle-sapp.js:18:70)
    at b (triangle-sapp.js:11:46)

The JS file location triangle-sapp.js:54:9 looks like this:

Screenshot 2023-10-08 at 18 36 28

The only place in library_webgpu.js which has a configure call seems to be:

var configuration = {
"device": device,
"format": WebGPU.TextureFormat[
{{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.format) }}}],
"usage": {{{ gpu.makeGetU32('descriptor', C_STRUCTS.WGPUSwapChainDescriptor.usage) }}},
"alphaMode": "opaque",
};
context["configure"](configuration);

I don't know what's needed to make such a JS shim closure-compatible, e.g. whether there are generally some sort of annotations missing, or only in this specific location. I could probably help with investigation and fixing if I would know where to start :)

Cheers!

(cc: @kainino0x)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions