aboutsummaryrefslogtreecommitdiff
path: root/src/library_browser.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/library_browser.js')
-rw-r--r--src/library_browser.js21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/library_browser.js b/src/library_browser.js
index 458a8dd2..9261a2cf 100644
--- a/src/library_browser.js
+++ b/src/library_browser.js
@@ -1,7 +1,6 @@
//"use strict";
// Utilities for browser environments
-
mergeInto(LibraryManager.library, {
$Browser__deps: ['$PATH'],
$Browser__postset: 'Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports
@@ -918,8 +917,11 @@ mergeInto(LibraryManager.library, {
var callbackId = msg.data['callbackId'];
var callbackInfo = info.callbacks[callbackId];
if (!callbackInfo) return; // no callback or callback removed meanwhile
- info.awaited--;
- info.callbacks[callbackId] = null; // TODO: reuse callbackIds, compress this
+ // Don't trash our callback state if we expect additional calls.
+ if (msg.data['finalResponse']) {
+ info.awaited--;
+ info.callbacks[callbackId] = null; // TODO: reuse callbackIds, compress this
+ }
var data = msg.data['data'];
if (data) {
if (!data.byteLength) data = new Uint8Array(data);
@@ -964,12 +966,23 @@ mergeInto(LibraryManager.library, {
});
},
+ emscripten_worker_respond_provisionally: function(data, size) {
+ if (!inWorkerCall) throw 'not in worker call!';
+ if (workerResponded) throw 'already responded with final response!';
+ postMessage({
+ 'callbackId': workerCallbackId,
+ 'finalResponse': false,
+ 'data': data ? new Uint8Array({{{ makeHEAPView('U8', 'data', 'data + size') }}}) : 0 // XXX copy to a new typed array as a workaround for chrome bug 169705
+ });
+ },
+
emscripten_worker_respond: function(data, size) {
if (!inWorkerCall) throw 'not in worker call!';
- if (workerResponded) throw 'already responded!';
+ if (workerResponded) throw 'already responded with final response!';
workerResponded = true;
postMessage({
'callbackId': workerCallbackId,
+ 'finalResponse': true,
'data': data ? new Uint8Array({{{ makeHEAPView('U8', 'data', 'data + size') }}}) : 0 // XXX copy to a new typed array as a workaround for chrome bug 169705
});
},