It seems the adding emscripten binding basing on emscripten::value_object with -s ASYNCIFY -s NO_DISABLE_EXCEPTION_CATCHING -s MAIN_MODULE=2 included is not actually working. I isolated the problem to following example:
main.cpp
#include <emscripten/bind.h>
int main()
{
return 0;
}
class TestEasyClass
{
public:
int member;
};
EMSCRIPTEN_BINDINGS(scope) {
emscripten::value_object<TestEasyClass>("TestEasyClass")
.field("member", &TestEasyClass::member);
}
main.js
import sampleModule from "./sample.js"
async function getWasmSample(wasmFilePath) {
try {
var locateFileOverride = function (wasmFileName) {
return wasmFilePath + "/" + wasmFileName;
};
const result = await sampleModule({ locateFile: locateFileOverride });
return result;
} catch (error) {
console.warn(
"[SampleLoader: getWasmSample] Failed to load module",
error
);
}
}
let wasmSample = getWasmSample('.')
It seems the adding emscripten binding basing on emscripten::value_object with
-s ASYNCIFY -s NO_DISABLE_EXCEPTION_CATCHING -s MAIN_MODULE=2
included is not actually working. I isolated the problem to following example:main.cpp
main.js
index.html
Compiling main.cpp using command line attached to bug report and then running in web browser causes following error occurs:
Commenting out the
EMSCRIPTEN_BINDINGS(scope)
block allows wasm module to instantiate properly.Version of emscripten/emsdk:
Full link command and output with -v appended:
em++ -s ASYNCIFY -s NO_DISABLE_EXCEPTION_CATCHING -s MAIN_MODULE=2 -s EXPORT_NAME=sampleModule -s EXPORT_ES6 --bind -v -g main.cpp -o src/sample.js