fabmax / physx-js-webidl

Javascript WASM bindings for Nvidia PhysX
MIT License
119 stars 28 forks source link

WASM Runtime Error on Safari #21

Open sheley1998 opened 1 year ago

sheley1998 commented 1 year ago

Thank you for your incredible work!

I've gotten everything to run on Chrome and Firefox. However, when I try execute PhysX() on Safari, I get the following error:

Unhandled Promise Rejection: RuntimeError: Aborted(CompileError: WebAssembly.Module doesn't parse at byte 5: can't get Function local's type in group 1, in function at index 4967)

I'm running Safari 16.2 on MacOS Ventura 13.1, Apple M1 chip

I'll try to build from source and see if there's anything I could change to get it to work. Would appreciate if you could look into it as well!

Cheers

fabmax commented 1 year ago

Hmm might be SIMD related. WASM SIMD support is still experimental, so Safari might not fully support it.

You can try to recompile the library with SIMD disabled by adding the following line to the physx/source/compiler/cmake/emscripten/CMakeLists.txt cmake file:

ADD_DEFINITIONS(-DPX_SIMD_DISABLED)
sheley1998 commented 1 year ago

Thanks for the tip. While that didn't seem to work, apparently the debug code path has SIMD disabled by default, which runs well in Safari. Unfortunately, debug build is 10mb larger than release build. I'll tinker with build settings some more, hopefully there's a better approach.

May2nd commented 4 months ago

I added ADD_DEFINITIONS(-DPX_SIMD_DISABLED=1) and remove -msimd128, it worked. Thanks.