- From: Charles Pritchard <chuck@jumis.com>
- Date: Tue, 08 Mar 2011 08:32:56 -0800
- To: Chris Marrin <cmarrin@apple.com>
- CC: Glenn Maynard <glenn@zewt.org>, Web Applications Working Group WG <public-webapps@w3.org>
On 3/7/2011 5:04 PM, Chris Marrin wrote: > On Mar 7, 2011, at 3:54 PM, Glenn Maynard wrote: > >> On Mon, Mar 7, 2011 at 6:05 PM, Chris Marrin<cmarrin@apple.com> wrote: >> Now that ArrayBuffer has made its way into XHR, I think it would be reasonable to somehow use this new object type as a way to pass data to and from Workers without copying. I've seen hints and thoughts about this here and there, but I've never seen a formal discussion. I'm not even sure if webapps is the place for this discussion, although it seems like a reasonable place. Please let me know if there is a better place. >> >> ArrayBuffer is the most obvious use for zero-copy messaging, but I don't think it should be limited to it... >> >> Has there been discussion anywhere that I've missed? >> >> Probably not the only one, but check the "WebWorkers and images" thread on whatwg. > Yeah, I thought about that case. The extra complication there is that images are rendering resources, which muddies the issues some. If the 2D Canvas API were able to use ArrayBuffer data as an image source like WebGL can, then we could kill 2 birds with one stone. Pass the ArrayBuffer to the worker and have it generate some image data, then pass it back and render it to a canvas. You could even split the array buffer into tiles and have multiple workers operate on the tiles. While we're throwing stones... I'd brought up the idea of adding a ".dispose()" method to ArrayBuffer, to queue a hint to the host that it's ok to release the array buffer on the next event loop. My idea was to hit easier memory management, while also signaling that an array buffer is ready for a zero-copy postMessage. buffer.dispose(); try { buffer.buffer[0]; } catch(e) { /* fails */ } postMessage(...); /* main window will receive the buffer */
Received on Tuesday, 8 March 2011 16:33:22 UTC