Weird memory issue with WebGL sample

Hello,

I am facing a weird issue with the WebGL sample.

First off, I have modified the sample as my goal is to load a STEP file into the web viewer. The problem I am having does not occur when I build the sample as is and load a .brep file.

Specifically, the issue I am having is that i get Chromes SBOX_FATAL_MEMORY_EXCEEDED error when loading a STEP file. (I also tried Edge and Firefox, no difference there)

The weird part: Everything works fine when i have Chromes development console open.
But, as soon as I close the console I get said error and the page crashes. If I load a .brep file without the console open, it works, but when I open and close the console then, it again crashes with the same error. This even happens before loading a model into the viewer. I clean my browsers cache before each try.

Here's what I added to the samples code to get it (kinda) working:

- I build the sample with -s TOTAL_MEMORY=32MB. I've tried different sizes ranging from 16MB to 2048MB. If I don't use this flag when building, I get a memory access out of bounds runtime error, which is shown in the console. Closing the console still produces the SBOX_FATAL_MEMORY_EXCEEDED error though.
- I have added a function openSTEPFromMemory() that basically mimics the already available openBRepFromMemory() function. Additionally, it makes use of STEPControl_Reader's ReadStream() function to read the file from memory and then I translate the STEP file into a TopoDS_Shape, which is then given to the AIS_Shape handle.
- I have edited the openFromMemory() function to detect STEP files.

Does anyone have an idea what could cause this behaiviour? Any help is much appreciated!

gkv311 n's picture

Browsers have known bugs with memory management when using Debug Console.

So, first of all - make sure if your issue is reproducible within clean nob-debughing environment (e.g. start new browser instance without opening Debugger even once, and check how your application behaves).

Jan-Niklas Velten's picture

Thank you for replying!

I have followed your suggestion and tried Chrome, Edge and Firefox in new instances, in normal as well as in incognito mode, all without opening the Debugger.

Chrome and Edge showed the same behaviour, Firefox at least did not crash, but didn't load the model either. Looking into its console afterwards showed Uncaught RuntimeError: index out of bounds two times, both call stacks originated from the emscripten-generated JS-Script. One started from createOccViewerModule, the other from openFromMemory. Both function calls were followed by a series of invoke function calls (I'm guessing this has something to do with the emscripten generated code?)

Do you by any chance have any further ideas?

Edit: I have built it again with the flags -s TOTAL_MEMORY=32MB and -s TOTAL_STACK=16MB. Chrome and Edge still show the same behaviour, but Firefox seems to be working without problems. So the issue could be connected to Chromium.