emscripten-core / emscripten-core/emscripten
emscripten_lazy_load_code causes errors on re-entry
- Dominant language
- C++
- Stars
- 27.6k
- Forks
- 3.6k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 105
Description
([Small repro repo](https://gist.github.com/surma/01ccc19a26752b61b4d41fd137b15146))
I am playing around with `emscripten_lazy_load_code` and I am running into an error.
C++ code:
```c++
void my_other_printf(int param) { printf(">>>>>%d\n", param); }
void my_main(int param) {
if (param < 3) {
printf(">%d\n", param);
} else {
emscripten_lazy_load_code();
my_other_printf(param);
}
}
```
On my page, I am hooking up a button that calls `my_main` with increasing integers. So first click `param=1`, second click `param=2`, etc. Once `param >= 3`, it uses the other code branch that triggers the lazy-loading.
The third click triggers the lazy load and succeeds. The forth click triggers some questionable fetches and errors. The fifth and any subsequent clicks succeed as expected.

Contributor guide
Assessment
This issue has not been assessed yet.