On the browser side when you recv binary data off websockets you get it as an ArrayBuffer or Blob.
Right now you cannot pass that to new Buffer() constructor.
Instead you need to convert the buffer to a Uint8Array, this conversion is very expensive for some reason.
Then once you get your output, you need to convert it again to a Uint8Array (which is now 50-100x more expensive since its an uncompressed image) if you want to use it for something like canvas element; ctx.putImageData(imageData, 0, 0) for example.
Is there anyway to optimize this, perhaps allow Uint8Array to be passed directly instead of Buffer?
This is with large ArrayBuffers like around 2-5MB uncompressed.
The actual decompression takes about 10-20ms, then the array conversion back into a Uint8Array takes 20ms-80ms, I think it depends on memory pressure.
On the browser side when you recv binary data off websockets you get it as an ArrayBuffer or Blob.
Right now you cannot pass that to new Buffer() constructor.
Instead you need to convert the buffer to a Uint8Array, this conversion is very expensive for some reason.
Then once you get your output, you need to convert it again to a Uint8Array (which is now 50-100x more expensive since its an uncompressed image) if you want to use it for something like canvas element; ctx.putImageData(imageData, 0, 0) for example.
Is there anyway to optimize this, perhaps allow Uint8Array to be passed directly instead of Buffer?
This is with large ArrayBuffers like around 2-5MB uncompressed.
The actual decompression takes about 10-20ms, then the array conversion back into a Uint8Array takes 20ms-80ms, I think it depends on memory pressure.