Fix stepping not working.
Use transferable object for sending arraybuffers to workers
This commit is contained in:
parent
d326cad611
commit
0e850b2a85
@ -111,25 +111,14 @@ async function bake(data) {
|
||||
})
|
||||
});
|
||||
} catch (err) {
|
||||
if (err instanceof DOMException) {
|
||||
self.postMessage({
|
||||
action: "bakeError",
|
||||
data: {
|
||||
error: err.message,
|
||||
id: data.id,
|
||||
inputNum: data.inputNum
|
||||
}
|
||||
});
|
||||
} else {
|
||||
self.postMessage({
|
||||
action: "bakeError",
|
||||
data: {
|
||||
error: err,
|
||||
id: data.id,
|
||||
inputNum: data.inputNum
|
||||
}
|
||||
});
|
||||
}
|
||||
self.postMessage({
|
||||
action: "bakeError",
|
||||
data: {
|
||||
error: err.message || err,
|
||||
id: data.id,
|
||||
inputNum: data.inputNum
|
||||
}
|
||||
});
|
||||
}
|
||||
self.inputNum = -1;
|
||||
}
|
||||
|
@ -69,7 +69,22 @@ class ControlsWaiter {
|
||||
* Handler for the 'Step through' command. Executes the next step of the recipe.
|
||||
*/
|
||||
stepClick() {
|
||||
this.app.bake(true);
|
||||
if (this.manager.worker.step) {
|
||||
// Step has already been clicked so get the data from the output
|
||||
const activeTab = this.manager.input.getActiveTab();
|
||||
this.manager.worker.queueInput({
|
||||
input: this.manager.output.getOutput(activeTab, true),
|
||||
inputNum: activeTab
|
||||
});
|
||||
this.app.progress = this.manager.output.outputs[activeTab].progress;
|
||||
this.app.bake(true);
|
||||
} else {
|
||||
// First click of step, so get the output from the inputWorker
|
||||
this.manager.input.inputWorker.postMessage({
|
||||
action: "step",
|
||||
data: this.manager.input.getActiveTab()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -267,7 +267,7 @@ class InputWaiter {
|
||||
this.manager.worker.queueInput(r.data);
|
||||
break;
|
||||
case "bake":
|
||||
this.app.bake(false);
|
||||
this.app.bake(r.data);
|
||||
break;
|
||||
case "displayTabSearchResults":
|
||||
this.displayTabSearchResults(r.data);
|
||||
|
@ -82,7 +82,7 @@ self.addEventListener("message", function(e) {
|
||||
self.changeTabLeft(r.data.activeTab, r.data.nums);
|
||||
break;
|
||||
case "autobake":
|
||||
self.autoBake(r.data);
|
||||
self.autoBake(r.data, false);
|
||||
break;
|
||||
case "filterTabs":
|
||||
self.filterTabs(r.data);
|
||||
@ -96,6 +96,9 @@ self.addEventListener("message", function(e) {
|
||||
case "updateTabHeader":
|
||||
self.updateTabHeader(r.data);
|
||||
break;
|
||||
case "step":
|
||||
self.autoBake(r.data, true);
|
||||
break;
|
||||
default:
|
||||
log.error(`Unknown action '${r.action}'.`);
|
||||
}
|
||||
@ -133,8 +136,10 @@ self.getLoadProgress = function(inputNum) {
|
||||
* Queues the active input and sends a bake command.
|
||||
*
|
||||
* @param {number} inputNum - The input to be baked
|
||||
* @param {boolean} [step=false] - Set to true if we should only execute one operation instead of the
|
||||
* whole recipe
|
||||
*/
|
||||
self.autoBake = function(inputNum) {
|
||||
self.autoBake = function(inputNum, step=false) {
|
||||
const input = self.getInputObj(inputNum);
|
||||
if (input) {
|
||||
let inputData = input.data;
|
||||
@ -150,7 +155,8 @@ self.autoBake = function(inputNum) {
|
||||
}
|
||||
});
|
||||
self.postMessage({
|
||||
action: "bake"
|
||||
action: "bake",
|
||||
data: step
|
||||
});
|
||||
}
|
||||
};
|
||||
@ -179,7 +185,8 @@ self.bakeAllInputs = function() {
|
||||
}
|
||||
}
|
||||
self.postMessage({
|
||||
action: "bake"
|
||||
action: "bake",
|
||||
data: false
|
||||
});
|
||||
|
||||
};
|
||||
|
@ -114,7 +114,8 @@ class OutputWaiter {
|
||||
statusMessage: `Input ${inputNum} has not been baked yet.`,
|
||||
error: null,
|
||||
status: "inactive",
|
||||
bakeId: -1
|
||||
bakeId: -1,
|
||||
progress: 0
|
||||
};
|
||||
|
||||
this.outputs[inputNum] = newOutput;
|
||||
@ -1300,7 +1301,6 @@ class OutputWaiter {
|
||||
});
|
||||
} else if (output.status === "baked" && showBaked) {
|
||||
let data = this.getOutput(iNum, false).slice(0, 4096);
|
||||
log.error(output);
|
||||
if (typeof data !== "string") {
|
||||
data = Utils.arrayBufferToStr(data);
|
||||
}
|
||||
|
@ -146,11 +146,15 @@ class WorkerWaiter {
|
||||
if (r.data.error) {
|
||||
this.app.handleError(r.data.error);
|
||||
this.manager.output.updateOutputError(r.data.error, inputNum, r.data.progress);
|
||||
} else if (r.data.progress !== this.manager.recipe.getConfig().length) {
|
||||
this.manager.output.updateOutputError(r.data.result, inputNum, r.data.progress);
|
||||
} else {
|
||||
this.updateOutput(r.data, r.data.inputNum, r.data.bakeId, r.data.progress);
|
||||
}
|
||||
this.app.progress = r.data.progress;
|
||||
|
||||
if (r.data.progress === this.recipeConfig.length) {
|
||||
this.step = false;
|
||||
}
|
||||
|
||||
this.workerFinished(currentWorker);
|
||||
break;
|
||||
case "bakeError":
|
||||
@ -328,7 +332,7 @@ class WorkerWaiter {
|
||||
this.chefWorkers[workerIdx].inputNum = nextInput.inputNum;
|
||||
this.chefWorkers[workerIdx].active = true;
|
||||
const input = nextInput.input;
|
||||
if (typeof input === "string") {
|
||||
if (input instanceof ArrayBuffer || ArrayBuffer.isView(input)) {
|
||||
this.chefWorkers[workerIdx].worker.postMessage({
|
||||
action: "bake",
|
||||
data: {
|
||||
@ -340,7 +344,7 @@ class WorkerWaiter {
|
||||
inputNum: nextInput.inputNum,
|
||||
bakeId: this.bakeId
|
||||
}
|
||||
});
|
||||
}, [input]);
|
||||
} else {
|
||||
this.chefWorkers[workerIdx].worker.postMessage({
|
||||
action: "bake",
|
||||
@ -353,7 +357,7 @@ class WorkerWaiter {
|
||||
inputNum: nextInput.inputNum,
|
||||
bakeId: this.bakeId
|
||||
}
|
||||
}, [nextInput.input]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user