W3C home > Mailing lists > Public > whatwg@whatwg.org > August 2012

Re: [whatwg] Binary Streaming with XHR

From: Nils Dagsson Moskopp <nils@dieweltistgarnichtso.net>
Date: Fri, 24 Aug 2012 14:04:32 +0200
To: Jussi Kalliokoski <jussi.kalliokoski@gmail.com>
Message-ID: <20120824140432.2de8f4db@desudesudesu>
Cc: whatwg@whatwg.org
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
Received on Friday, 24 August 2012 12:06:38 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:44 UTC