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

Javascript calls to wasm version of libzim/kiwix-lib only work the first time #509

Closed
mossroy opened this issue Jun 1, 2019 · 2 comments

Comments

@mossroy
Copy link
Contributor

mossroy commented Jun 1, 2019

This is a follow-up of #116.

After the first call, all subsequent calls fail with the following error in the browser console :
Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)

There's certainly something wrong in the way I implemented that, but the runtime was ready for the first working call.

Here is how to reproduce :

The bindings are currently implemented with embind, in file demo_file_api.cpp. This test case only uses the getArticleCount function (same name in C and javascript).

If one wants to modify and recompile the C code, it can be done with make (see the provided Makefile, you'll need emscripten and a few libraries) or ran inside a docker container (that already contains everything). See https://github.com/mossroy/libzim_wasm/blob/master/README.md for how to do it.

@mossroy mossroy added this to the v2.6 milestone Jun 1, 2019
@mossroy mossroy modified the milestones: v2.6, v2.7 Jul 14, 2019
@mossroy mossroy modified the milestones: v2.7, v2.8 Mar 29, 2020
@mossroy mossroy modified the milestones: v2.8, v2.9 Jul 11, 2020
@Jaifroid Jaifroid modified the milestones: v3.0, v3.1 Oct 3, 2020
@Jaifroid Jaifroid modified the milestones: v3.1, v3.2 Dec 6, 2020
@mossroy mossroy modified the milestones: v3.2, v3.3 Aug 22, 2021
@mossroy
Copy link
Contributor Author

mossroy commented Oct 25, 2021

This seems to be improved with version 2.0.32 of emscripten.
It now works to call several times the libzim APIs, which is cool.
But there is each time an error message in the browser console :

Uncaught RuntimeError: Aborted(Module.thisProgram has been replaced with plain thisProgram (the initial value can be provided on Module, but after startup the value is only looked for on a local variable of that name))

So there is probably something to fix in our code anyway

@mossroy
Copy link
Contributor Author

mossroy commented Oct 27, 2021

I could fix this by changing the lifecycle of the wasm module : it's (re)-initialized only when the user chooses another ZIM file(s)

@mossroy mossroy closed this as completed Oct 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants