3 ms·
what would also be nice is shared read-only Canvas, etc. available in Web Workers so image processing (specifically analysis steps) can be paralellized without
by leeoniya 12y ago
what would also be nice is shared read-only Canvas, etc. available in Web Workers so image processing (specifically analysis steps) can be paralellized without copying the entire canvas (or parts of it) through message passing.
- sitkack 12y agoI feel like there needs to be a gamejam / instant runoff election of features for webworkers, so much opportunity is being squandered by what could be an elegant solution to many peoples' problems.
- satori99 12y agoIf you use Web Workers, you are going to have to use message passing. There is no other way to communicate with a Worker. There are no truly shared objects between js threads. However, it is still possible to post binary data to a worker and back again without making a copy of it, by using Transferable Objects [1]. You simply have to provide an array of the arraybuffers to move as the second paramter to postMessage(). The caveat is that the data is no longer available to the posting thread after the postMessage call (TypedArray length will be zero). [1] http://updates.html5rocks.com/2011/12/Transferable-Objects-Lightning-Fast http://updates.html5rocks.com/2011/12/Transferable-Objects-L...
- leeoniya 12y agoi'm aware of transferable objects, but it really defeats the purpose of parallelizing analysis of the same thing if that thing becomes unavailable to read after transfer. it would be great to just tell a worker to read a specific bounding box from an existing canvas without having to give up the canvas entirely or copying the bounding box contents into it.
- satori99 12y agoYeah, that would be awesome. Probably not going to happen with actual DOM objects anytime soon.