emscripten-core / emscripten-core/emscripten

emscripten_request_animation_frame_loop(), emscripten_set_main_loop(), emscripten_set_timeout() etc. are not compatible with JSPI

Open
#22,493 18 comments 0 reactions 1 assignee Claimed by @brendandahl View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I'm taking a peek at my WebGPU bindings JSPI support test, and I find that after updating to latest Emscripten, I now start getting this error:

```
Uncaught RuntimeError: attempting to suspend without a WebAssembly.promising export
```

![image](https://github.com/user-attachments/assets/08fed7e8-ae79-4fa6-889c-56a195cf9f0a)

I wonder if something might have changed in the JSPI implementation since an earlier Emscripten version, that my code is now out of date?

Here is how I handle JSPI:

https://github.com/juj/wasm_webgpu/blob/16bbfed542979a2f15f789cd0461cce7bb30e0e6/lib/lib_webgpu.js#L1427-L1449

i.e. I use a pattern

```
lib_webgpu.js
```

```js
wgpu_buffer_map_sync__sig: 'ii',
wgpu_buffer_map_sync__async: true,
wgpu_buffer_map_sync: function(buffer) {
return Asyncify.handleAsync(() => {
return wgpu[buffer].mapAsync(); // .mapAsync() returns a promise
},
```

This used to work with both Asyncify and JSPI at some point - but maybe the syntax, or something else has changed?

It's been a while since I followed this feature. I tried to search https://emscripten.org/docs/porting/asyncify.html for documentation example of how to use `Asyncify.handleAsync()`, though there is only a `EM_JS()` based example, which I don't want to use. So I wonder if that changes anything, or if the code should work identically as a JS lib?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.