i’m running inferencing runtime in a worker, which generates Float32 array images.
Then i need to send this array to main thread, using postMessage.
During profiling i found many strange things.
- Surprisingly worker made inferencing about 3 times slower (8ms without worker vs 20ms with worker).
- In main thread there is about 20ms time spent in onmessage function.
Didn’t expect that sending 512 x 256 float32 buffer would be so slow.
Currently i’m trying to send ImageBitmap instead of Float32Array. But i didn’t find way to create ImageBitmap from float32array. Is ImageBitmap supports floating point at all?
If not, how can i transfer the array data from worker to main efficiently?