Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asynchronous WasmThemis initialization #507

Merged
merged 1 commit into from
Jul 23, 2019

Commits on Jul 23, 2019

  1. Asynchronous WasmThemis initialization

    It turns out that WebAssembly is compiled and loaded asynchronously [1].
    There is an option for synchronous compilation, but Chrome and Electron
    support only asynchronous loading. This means that one cannot simply
    call C functions. We need to wait for WebAssembly to be compiled and
    Emscripten runtime to boot. This is performed automatically if the whole
    application is compiled by Emscripten, but Themis is a library.
    
    Emscripten provides an "onRuntimeInitialized" callback which is called
    when Emscripten startup is complete and C functions can be called.
    Expose an interface to this callback as JavaScript promise which is
    resolved once initialization is complete. The users should call Themis
    functions only after this promise is resolved. (Alternatively, they can
    wait for a second or two.)
    
    This behavior is not reproduced by unit tests because Mocha launches
    asynchronously too and it manages to start testing after WasmThemis
    loading is complete. But we can test that the promise is resolved.
    
    [1]: https://emscripten.org/docs/compiling/WebAssembly.html#wasm-files-and-compilation
    ilammy committed Jul 23, 2019
    Configuration menu
    Copy the full SHA
    d2caa62 View commit details
    Browse the repository at this point in the history