From a750b0f08aae6afa70d2fac71b591c9f4627915f Mon Sep 17 00:00:00 2001 From: j433866 Date: Thu, 16 May 2019 10:42:27 +0100 Subject: [PATCH] Use transferable objects to send arraybuffers back to the workerwaiter --- src/core/ChefWorker.js | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/core/ChefWorker.js b/src/core/ChefWorker.js index 8b871c94..7306a63e 100644 --- a/src/core/ChefWorker.js +++ b/src/core/ChefWorker.js @@ -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",