emscripten-core/emscripten

MAIN_MODULE and emscripten_fetch

Open

#11,407 opened on 2020年6月12日

GitHub で見る
 (5 comments) (0 reactions) (0 assignees)C++ (3,519 forks)batch import
help wanted

Repository metrics

Stars
 (27,361 stars)
PR merge metrics
 (平均マージ 19d 10h) (30d で 147 merged PRs)

説明

Dear all,

I experience problems using the Fetch API together with WebAssembly modules.

Firstly, I copy/paste the exact sample code from the Introduction section of the Fetch API, and put it inside a file called test.c.

Secondly, I create a basic index.html as follows:

<html>
  <body>
    <h1>Test</h1>
    <script async type="text/javascript" src="test.js"></script>
  </body>
</html>

Finally, I compile the WebAssembly binaries (version 1.39.17 of Emscripten), and serve them using Python as follows:

export FLAGS="-s MAIN_MODULE=1 -s EXPORT_ALL=1 -s FETCH=1 -s WASM=1"
~/Downloads/emsdk/upstream/emscripten/emcc ${FLAGS} -DNDEBUG -O2 -o test.o -c test.c
~/Downloads/emsdk/upstream/emscripten/emcc ${FLAGS} -DNDEBUG -O2 test.o -o test.js
python -m SimpleHTTPServer 8000

When I open http://localhost:8000/, I get the following errors in the console:

  • Maximum call stack size exceeded on Chromium, and
  • InternalError: too much recursion,__emscripten_fetch_load_cached_data on Firefox.

The problem disappears if I don't use modules (i.e. if I remove -s MAIN_MODULE=1). Would the Fetch API be incompatible with WebAssembly modules? Is there a way to solve this issue?

Thanks for your great work on Emscripten!

コントリビューターガイド