Hi.
Even after reading this:
http://kripken.github.io/emscripten-site/docs/getting_started/FAQ.html#how-can-i-tell-when-the-page-is-fully-loaded-and-it-is-safe-to-call-compiled-functions
I'm not sure how to deal with the error:
"run() called, but dependencies remain, so not running" avc-codec.js:4
"Assertion failed: you need to wait for the runtime to be ready
(e.g. wait for main() to be called)"
Consider this simple example:
---------------8<------------------------- hello.c
#include <stdio.h>
void foo(void)
{
printf("foo\n");
}
void bar(void)
{
printf("bar\n");
}
---------------8<---------------------------------
Compile with:
/path/to/emcc hello.c -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=1 -s EXPORTED_FUNCTIONS="['_foo', '_bar']" -O2 -o hello.js
---------------8<------------------------- hello.html
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Emscripten-Generated Code</title>
<script type="text/javascript" src="hello.js"></script>
<script type="text/javascript">
_foo();
_bar();
</script>
</body>
</html>
-------------8<---------------------------------------
Now if I run the file from Firefox I get:
TypeError: asm.js type error: Disabled by debugger hello.js
uncaught exception: abort() at jsStackTrace@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.js:1:18829
stackTrace@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.js:1:19012
abort@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.js:12:5432
assert@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.js:1:8677
asm._foo@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.js:12:727
@file:///home/stefano/src/Sandbox/JavaScript/emscripten/hello.html:9:7
"run() called, but dependencies remain, so not running" hello.js:1
"Assertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)" hello.js:1
[Note also that with -O1 this won't happen.]
It's not really clear to me how to apply the solutions suggested in
the FAQ.
|The easiest way to find out when loading is complete is to add a
|main() function, and within it call a JavaScript function to notify
|your code that loading is complete.
Consider this one:
---------------8<------------------------- hello2.c
#include <stdio.h>
#include <emscripten.h>
void foo(void)
{
printf("foo\n");
}
void bar(void)
{
printf("bar\n");
}
int main() {
EM_ASM( allReady() );
return 0;
}
---------------8<-------------------------------------
---------------8<------------------------- hello2.html
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Emscripten-Generated Code</title>
<script type="text/javascript">
function allReady() {
_foo();
_bar();
}
</script>
<script type="text/javascript" src="hello2.js"></script>
</script>
</body>
</html>
---------------8<-----------------------------------
Compiling it with:
/path/to/emcc hello2.c -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1 -s EXPORTED_FUNCTIONS="['_foo', '_bar']" -O2 -o hello2.js
I still get:
"run() called, but dependencies remain, so not running" hello.js:1
"pre-main prep time: 26 ms" hello.js:1
and no main() function nor allReady() function is called.
[Same effect if I switch to -O1.]
What am I missing?
TIA