Unable to compile WebAssembly app when STEPCAFControl_Reader is used.

I'm trying to read a step file and display it. When I create a STEPCAFControl_Reader object, compile will fail with the following error:

em++: error: 'D:/emsdk/upstream\bin\wasm-emscripten-finalize --minimize-wasm-changes -g --dyncalls-i64 --dwarf occt-webgl-sample.wasm -o occt-webgl-sample.wasm --detect-features' failed (returned 3221226505)
mingw32-make[2]: *** [src/occt-webgl-sample.js] Error 1
mingw32-make[1]: *** [src/CMakeFiles/occt-webgl-sample.dir/all] Error 2
mingw32-make: *** [all] Error 2
emmake: error: 'D:\emsdk\mingw\4.6.2_32bit\mingw32-make.exe install' failed (returned 2)

The code snippet causing the issue is as shown below. The error occurs once "STEPCAFControl_Reader cafReader;" is used.

Handle(TDocStd_Document) StepModelLoader::Load()
{
    //Create XDE document.
    Handle(TDocStd_Application) app = new TDocStd_Application;
    BinXCAFDrivers::DefineFormat(app);
    Handle(TDocStd_Document) doc;
    app->NewDocument("BinXCAF", doc);

    STEPCAFControl_Reader cafReader;
    // STEPControl_Reader& reader = cafReader.ChangeReader();
    
    return doc;
}

I'm wondering if OCAF supports webassembly? Or do I missing something? I've attached my test code

Attachments: 
Kirill Gavrilov's picture

I'm wondering if OCAF supports webassembly?

It is not OCAF that should support WebAssembly, but rather Emscripten SDK as a cross-compiler toolchain should be able to build an OCAF-based application. According to my current experience - it should. Compiler output "returned 3221226505" with some magic number usually indicates some internal error in building toolchain itself. So you may try different building options / different Emscripten SDK versions or report bug to them.

RockWithBoA's picture

Thank you for your help. I reported for Emscripten and it turns out that it is related to the drawf info being generated during build in debug mode. wasm-emscripten-finalize needs to consume a lot of memory (more than 10 GB) to generate that info and it crashes due to out of memory.

Kirill Gavrilov's picture

Indeed, debug build by Emscripten takes more than 17 GiB of memory in peak.