Runtime exceptions and Emscripten WebGL support linker options

64 views
Skip to first unread message

Kevin Cain

unread,
Dec 13, 2021, 1:53:59 AM12/13/21
to emscripten-discuss
I've made some first steps in Emscripten via the tutorials, and have now begun to retarget a working program to the browser.

The candidate program compiles without errors via CMake without any special linker directive to limit the GL calls (LEGACY_GL_EMULATION, MAX_WEBGL_VERSION=2) with:

emcmake cmake -DPLATFORM=Web
emmake make

At runtime in a local python server I see uncaught exceptions. How might I tell if those errors are due to limitations in Emscripen WebGL support?

A more general question: how best to debug these exceptions in the browser?

Floh

unread,
Dec 14, 2021, 7:44:59 AM12/14/21
to emscripten-discuss
What do the exception messages say? Also are you seeing any suspicious messages about missing functions in the build process? E.g. if any GL functions are not implemented by the Emscripten WebGL wrapper it would most likely already show up as warnings during the linker stage.

Another (more likely) reason is that the code which worked fine on "desktop GL" has problems with WebGL's much stricter specification and validation, in that case the error messages in the JS console usually provide a hint about what's going wrong.

The only advice I can give regarding debugging is to compile with -g so that Emscripten doesn't do any minification or name mangling, that way the callstack in the exception messages is readable (functions have their expected names instead of being minified). IME usually that's enough to figure out what's going wrong.

Cheers,
-Floh.

Kevin Cain

unread,
Dec 16, 2021, 12:16:59 AM12/16/21
to emscripten-discuss
Thanks @Floh for your suggestions; to answer your question, I'm using emcmake + emmake -- I see build warnings *except* noting that libraries will be compiled statically, not dynamically. Nothing about missing functions per se.

Since the exceptions are uncaught, I don't get any explicit exception message. I'm using Chrome tools to trace execution, but perhaps through unfamiliarity I'm missing something.

Thanks,

-Kevin

Kevin Cain

unread,
Dec 16, 2021, 12:22:37 AM12/16/21
to emscripten-discuss
A quick addendum: when calling the compiled binary via node.js (rather than local serving to the browser) I get the message 'ReferenceError: document is not defined'.

I am attempting to preload a file for local use using the following:
target_link_libraries(plyv "--preload-file apple.ply")

As I understand it, this syntax will expect the referenced file in the calling path.
Reply all
Reply to author
Forward
0 new messages