OpenCascade - WebAssembly use

Hi,

Im trying to create small webassemby module converting IGES to VRML file.

C++ code compiled to "normal" application work ok. Emscripten compilation runs ok.  Then im loading created .js file to my page

Binded (EmBind) functions called from java script runs ok unless such function declares  IGESCAFControl_Reader object:

IGESCAFControl_Reader reader;

then error occurs in browser console "

Uncaught (in promise) getpwuid: TODO

Further investigations shows that problems is generated by IGESControl_Controller::Init() method in GESCAFControl_Reader constructor which construct IGESControl_Controller:

Handle(IGESControl_Controller) ADIGES = new IGESControl_Controller(Standard_False);

What may be reason for such error, and is there way to correct it?

Regards

Adam

Kirill Gavrilov's picture
Uncaught (in promise) getpwuid: TODO

I believe, this could be a bug in Emscripten related to this function - it is probably has no implementation.
Compilation using this function (in OSD_Process.cxx) goes well, while causing a failure in runtime - which is unexpected behavior (either there should be a compile-time/link-time error or function should work as expected).
So I would report a bug to Emscripten project and see what they will say.

As a workaround, you may patch OSD_Process.cxx to avoid this function call - this function may unlikely be implemented in a reliable way in JavaScript world, so a fallback could be provided with "#ifdef __EMSCRIPTEN__" check.
I've seen a patch related to getpwuid() in some OCCT fork, but as it wasn't accompanied with a comment "why", I didn't understand what for it was done.

Don't forget to report a bug on OCCT Bugtracker if you will consider patching OCCT itself.

Adam Wnek's picture

Hi,

Thank you for your support. The patch you proposed works. I will report this as you suggested at the evening.

Thanks