[whatwg] Binary Streaming with XHR

Nils Dagsson Moskopp nils at dieweltistgarnichtso.net
Fri Aug 24 05:04:32 PDT 2012


Jussi Kalliokoski <jussi.kalliokoski at 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>



More information about the whatwg mailing list