Open derRaab opened 4 years ago
I guess that's because the Bytes instance is created with js.node.Buffer.hxToBytes()
?
I wonder if my conversion method will double the memory usage. And especially if loading a big media file that processing does take a while. Hm.
Hi! I'm not sure if that is even an issue, but it took me a while to understand the difference between the Browser based implementation and the one used by node (electron). So I figured others might run into this very specific case as well:
In a nutshell this is the actual runtime difference:
Bytes.getData()
returnsArrayBuffer
in the browser butBuffer
in node (electron):If you're interested - first the JavaScript runtime error I ran into:
This is my little handler causing problems where _audioContext is an
AudioContext
instance:This is my bytes receiving handler, which extracts the needed
ArrayBuffer
and forwards it:So if I use Google Chrome and Http to load the bytes it works fine:
BUT if I use the File API to read the bytes, decoding audio throws the TypeError:
After some research I figured out, that running node (electron),
Bytes.getData()
actually returns ajs.node.Buffer
instance:So in my case I had to convert the node buffer into an array buffer, which led me to this quite old stack overflow answer: https://stackoverflow.com/questions/8609289/convert-a-binary-nodejs-buffer-to-javascript-arraybuffer/31394257#31394257
Just in case you need that:
So is Bytes.getData() not consistent on all platforms? Is this expected behaviour? Or is this just a very rare edge case?