Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transferable support for binary arrow files #42

Merged
merged 3 commits into from
Feb 12, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Transfer wasm file during cross-origin loading
  • Loading branch information
nmichaud committed Feb 12, 2018
commit 881afe9a0670dd328cf96e8f69bf09d5ddf0698e
16 changes: 11 additions & 5 deletions packages/perspective/src/js/perspective.parallel.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ function worker() {
} else {
this._start_cross_origin();
}
this._detect_transferable();
}

worker.prototype._detect_transferable = function() {
Expand All @@ -204,6 +203,7 @@ worker.prototype._start_cross_origin = function() {
this._worker.postMessage = worker.postMessage.bind(worker);
this._worker.terminate = worker.terminate.bind(worker);
this._worker = worker;
this._detect_transferable();
this._worker.addEventListener('message', this._handle.bind(this));
if (typeof WebAssembly === 'undefined') {
this._start_cross_origin_asmjs();
Expand All @@ -224,13 +224,18 @@ worker.prototype._start_cross_origin_wasm = function() {
var wasmXHR = new XMLHttpRequest();
wasmXHR.open('GET', __SCRIPT_PATH__.path() + 'wasm_async/psp.wasm', true);
wasmXHR.responseType = 'arraybuffer';
wasmXHR.onload = function() {
this._worker.postMessage({
wasmXHR.onload = () => {
let msg = {
cmd: 'init',
data: wasmXHR.response,
path: __SCRIPT_PATH__.path()
});
}.bind(this);
};
if (this._worker.transferable) {
this._worker.postMessage(msg, [wasmXHR.response]);
} else {
this._worker.postMessage(msg);
}
};
wasmXHR.send(null);
}

Expand All @@ -248,6 +253,7 @@ worker.prototype._start_same_origin = function() {
this._worker = w;
this._worker.addEventListener('message', this._handle.bind(this));
this._worker.postMessage({cmd: 'init', path: __SCRIPT_PATH__.path()});
this._detect_transferable();
};

let _initialized = false;
Expand Down