fix for transferrable objects not being transferred. remove dead code

This commit is contained in:
Stewart Allen 2022-10-15 10:53:08 -04:00
commit 834654d62f
2 changed files with 7 additions and 17 deletions

View file

@ -641,23 +641,18 @@ kiri.worker = {
} }
}; };
dispatch.send = (msg) => { dispatch.send = (msg, direct) => {
// console.log('worker send', msg); self.postMessage(msg, direct);
self.postMessage(msg);
}; };
dispatch.onmessage = self.onmessage = function(e) { dispatch.onmessage = self.onmessage = function(e) {
// console.log('worker recv', e);
let time_recv = time(), let time_recv = time(),
msg = e.data || {}, msg = e.data || {},
run = dispatch[msg.task], run = dispatch[msg.task],
send = { send = {
data : function(data,direct) { data : function(data,direct) {
// if (direct && direct.length) { // if (direct && direct.length) {
// console.log({ // console.log( direct.map(z => z.byteLength).reduce((a,v) => a+v) );
// zeros: direct.length,
// sz:direct.map(z => z.byteLength)
// });
// } // }
dispatch.send({ dispatch.send({
seq: msg.seq, seq: msg.seq,
@ -665,14 +660,11 @@ dispatch.onmessage = self.onmessage = function(e) {
done: false, done: false,
data: data data: data
}, direct); }, direct);
// if (direct && direct.length) {
// console.log( direct.map(z => z.byteLength).reduce((a,v) => a+v) );
// }
}, },
done : function(data,direct) { done : function(data,direct) {
// if (direct && direct.length) {
// console.log({
// zeros: direct.length,
// sz:direct.map(z => z.byteLength).reduce((a,v) => a+v)
// });
// }
dispatch.send({ dispatch.send({
seq: msg.seq, seq: msg.seq,
task: msg.task, task: msg.task,
@ -699,7 +691,6 @@ dispatch.onmessage = self.onmessage = function(e) {
data: output data: output
}); });
} catch (wrkerr) { } catch (wrkerr) {
// console.log(wrkerr);
console.trace(wrkerr.stack); console.trace(wrkerr.stack);
send.done({error: wrkerr.toString()}); send.done({error: wrkerr.toString()});
} }

View file

@ -13,7 +13,6 @@ gapp.register("kiri.codec", [], (root, exports) => {
const { base, kiri } = root; const { base, kiri } = root;
const handlers = {}; const handlers = {};
const freeMem = true; const freeMem = true;
const zeroOut = true;
const codec = exports({ const codec = exports({
undef: undefined, undef: undefined,
@ -76,7 +75,7 @@ function allocFloat32Array(arg, zeros) {
// usually a number (size) for array // usually a number (size) for array
f32 = new Float32Array(arg); f32 = new Float32Array(arg);
} }
if (zeroOut && zeros && f32.byteLength > 0) { if (zeros && f32.byteLength > 0) {
zeros.push(f32.buffer); zeros.push(f32.buffer);
} }
return f32; return f32;