emscripten-core / emscripten-core/emscripten
Cannot convert a BigInt value to a number when calling wgpuCreateInstance
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
When calling `wgpuCreateInstance`, Chromium errors with
`Cannot convert a BigInt value to a number`
Offending code:
```cpp
WGPUInstance instance = wgpuCreateInstance(nullptr);
```
based on this code in Emscripten tests: https://github.com/emscripten-core/emscripten/blob/0566a76b500bd2bbd535e108f657fce1db7f6f75/test/webgpu_basic_rendering.cpp#L20
Chrome highlights this line in the webassembly as the source of the error:
```wasm
call $wgpuCreateInstance
```
Browser version:
Chromium Version 118.0.5987.0 (Developer Build) (64-bit)
**Version of emscripten/emsdk:**
```
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.45 (ef3e4e3b044de98e1811546e0bc605c65d3412f4)
clang version 18.0.0 (https://github.com/llvm/llvm-project d1e685df45dc5944b43d2547d0138cd4a3ee4efe)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: C:\Users\Admin\Documents\emsdk\upstream\bin
```
**Workaround**
```cpp
instance = reinterpret_cast(1ull);
```
This hack allows my code to continue by tricking the implementation into thinking that I called `wgpuCreateInstance`.
Contributor guide
Assessment
This issue has not been assessed yet.