Use transferable objects to send arraybuffers back to the workerwaiter

This commit is contained in:
j433866 2019-05-16 10:42:27 +01:00
parent 0e850b2a85
commit a750b0f08a
1 changed files with 20 additions and 8 deletions

View File

@ -102,14 +102,26 @@ async function bake(data) {
data.progress, // The current position in the recipe
data.step // Whether or not to take one step or execute the whole recipe
);
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum,
bakeId: data.bakeId
})
});
if (data.input instanceof ArrayBuffer) {
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum,
bakeId: data.bakeId
})
}, [data.input]);
} else {
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id,
inputNum: data.inputNum,
bakeId: data.bakeId
})
});
}
} catch (err) {
self.postMessage({
action: "bakeError",