Re: [whatwg] Binary Streaming with XHR

Jussi Kalliokoski <jussi.kalliokoski@gmail.com> schrieb am Fri, 24 Aug
2012 13:23:03 +0300:

>[…]
>
> My first idea was that if you set a property called "chunkSize" on
> the XHR, it would start dispatching an event called "onchunk"
> whenever a chunk of that size has been loaded. That event would
> contain a property "chunk" that would be an array buffer containing
> that data. However, I'm having second thoughts on that approach as it
> is likely to produce a lot of garbage.

Can you elaborate on the nature of the lot of garbage you are expecting?

> Instead, my refined idea is that you'd set a "chunk" property on the
> XHR to an ArrayBuffer, and each time a chunk of the size of the
> "chunk" was ready, it would set the values of the "chunk" property
> accordingly and the "onchunk" event would be dispatched.

Maybe I have not understood it, but at first glance that approach seems
prone to race conditions. What happens if the next chunk is ready while
the “onchunk“ event for the last one has not been processed? Does the
“chunk” property get overwritten and the previous chunk's data is lost?

-- 
Nils Dagsson Moskopp // erlehmann
<http://dieweltistgarnichtso.net>

Received on Friday, 24 August 2012 12:06:38 UTC