aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/library.js18
-rw-r--r--src/postamble.js4
-rw-r--r--src/preamble.js13
3 files changed, 16 insertions, 19 deletions
diff --git a/src/library.js b/src/library.js
index 7cda8bbb..8f4e5799 100644
--- a/src/library.js
+++ b/src/library.js
@@ -255,23 +255,7 @@ LibraryManager.library = {
var success = true;
if (typeof XMLHttpRequest !== 'undefined') {
// Browser.
- // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available.
- var xhr = new XMLHttpRequest();
- xhr.open('GET', obj.url, false);
-
- // Some hints to the browser that we want binary data.
- if (typeof Uint8Array != 'undefined') xhr.responseType = 'arraybuffer';
- if (xhr.overrideMimeType) {
- xhr.overrideMimeType('text/plain; charset=x-user-defined');
- }
-
- xhr.send(null);
- if (xhr.status != 200 && xhr.status != 0) success = false;
- if (xhr.response !== undefined) {
- obj.contents = new Uint8Array(xhr.response || []);
- } else {
- obj.contents = intArrayFromString(xhr.responseText || '', true);
- }
+ assert('Cannot do synchronous binary XHRs in modern browsers. Use --embed-file or --preload-file in emcc');
} else if (typeof read !== 'undefined') {
// Command-line.
try {
diff --git a/src/postamble.js b/src/postamble.js
index 56f0aee1..7371ff05 100644
--- a/src/postamble.js
+++ b/src/postamble.js
@@ -53,10 +53,10 @@ if (Module['preRun']) {
#if INVOKE_RUN
#else
-Module['noInitialRun'] = true;
+addRunDependency();
#endif
-if (!Module['noInitialRun']) {
+if (runDependencies == 0) {
var ret = run();
#if CATCH_EXIT_CODE
print('Exit Status: ' + ret);
diff --git a/src/preamble.js b/src/preamble.js
index afae5ea7..ae7bd660 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -873,5 +873,18 @@ var STRING_TABLE = [];
{{{ unSign }}}
{{{ reSign }}}
+// A counter of dependencies for calling run(). If we need to
+// do asynchronous work before running, increment this and
+// decrement it. Incrementing must happen in Module.preRun
+// or PRE_RUN_ADDITIONS (used by emcc to add file preloading).
+var runDependencies = 0;
+function addRunDependency() {
+ runDependencies++;
+}
+function removeRunDependency() {
+ runDependencies--;
+ if (runDependencies == 0) run();
+}
+
// === Body ===