Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Feature Request VERY IMPORTANT: Allow dlopen on WebGL

Discussion in 'Web' started by Lanre, Nov 12, 2023.

  1. Lanre


    Dec 26, 2013
    Hey all,

    We're building a platform that allows for dynamically downloading and linking a compiled functions (in this case, WASM binaries) at runtime. Our infrastructure is built to support invoking these either directly from JavaScript (using emscripten bindings) or from Unity.

    For use within Unity, we need to be able to link the compiled WASM at runtime, relying on `dlopen` and `dlsym`. But Unity's generated `Web.framework.js` specifically strips out the necessary scaffolding (`__dlopen_js`, `__dlsym_js`, `__emscripten_dlopen_js` (removing this one is particularly sinister)).

    Instead of completely disabling everyone's ability to use `dlfcn.h`, why not add a compiler option in `PlayerSetings.WebGL`, like `enableDynamicLinking` which defaults to `false`? The key here is to make it possible for devs who need this functionality and know how to use it.

    In the mean time, what is the best way to monkeypatch Unity's `Web.framework.js` to re-add the bindings that Unity removed?

    cc @jukka_j