emscripten icon indicating copy to clipboard operation
emscripten copied to clipboard

CGAL freezes on boolean operations

Open Hedrig opened this issue 1 year ago • 3 comments
trafficstars

It seems that CGAL's boolean operation hang the browser indefinitely. This occurs from time to time seemingly at random. I have heard it's because CGAL's rounding modes are not imported correctly to WebAssembly. Is that true? Is there a way to use CGAL with Emscripten as to avoid the issue?

emcc -v output: emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1314672a25699846b4663701bcb6f69cca) clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb) Target: wasm32-unknown-emscripten Thread model: posix InstalledDir: /home/medal/projects/emsdk/upstream/bin

Hedrig avatar Mar 21 '24 07:03 Hedrig

If you run with devtools open can you see what it happening when you such as hang?

I'm not sure what you mean by "rounding modes are not imported correctly to WebAssembly". Wasm doesn't support different rounding modes as of today but I don't see who that would cause browser hands, especially non-deterministic ones.

sbc100 avatar Mar 21 '24 19:03 sbc100

Okay, after researching the problem a while more, I have identified the problem. It seems that one of CGAL's operations is using recursion, which causes an unhandled stack overflow exception. I have two questions:

  1. Is it possible to increase Javascript stack size to prevent the exception?
  2. Is it possible to handle the exception given that it occurs within the Javascript runtime?

Hedrig avatar Apr 16 '24 11:04 Hedrig

Here is some information on javascript stack overflows: https://humanwhocodes.com/blog/2009/05/19/javascript-stack-overflow-error/

Yes you can catch them, and no it not possible to control the stack size in the wild (You can do it with browser flag I suppose but that probably don't work for more folks).

sbc100 avatar Apr 16 '24 16:04 sbc100