Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Investigate uploading Blobs/ArrayBuffers #30

Closed
silverwind opened this Issue Feb 18, 2014 · 10 comments

Comments

Projects
None yet
2 participants
Owner

silverwind commented Feb 18, 2014

FormData has quite a few cross-browser issues and also adds the overhead of a multipart-parser on the server. It might be cleaner to just upload Blobs (or ArrayBuffers) over the Websocket instead.

Collaborator

colelawrence commented Feb 18, 2014

This is different than streaming binary right? It should make everything easier, but mobile devices don't really support raw websockets so we also need to be sure socket.io would support blobs from Android or Safari Mobile.

Owner

silverwind commented Feb 19, 2014

WebSocket support actually isn't that bad anymore, it's pretty much the same as for Flexbox flexbox-support, which I require:

http://caniuse.com/websockets
http://caniuse.com/flexbox

I'd say it's too much work to support a non-flexbox layout, so I think we'll stay on raw sockets.

Collaborator

colelawrence commented Feb 19, 2014

Okay, cool I was unaware

Owner

silverwind commented Feb 19, 2014

Android's default browser is the only one in that list, that only recently got these two features, and it's in a pretty dire state of supporting other much-needed features. I fully support IOS7/Chrome on Android though, fyi.

Owner

silverwind commented Feb 20, 2014

Thanks!

(I'll assign us to the issues, so we can keep track)

@colelawrence colelawrence removed their assignment Mar 2, 2014

@silverwind silverwind changed the title from Investigate uploading Blobs to Investigate uploading Blobs/ArrayBuffers Aug 3, 2014

Owner

silverwind commented Mar 28, 2015

Tested a bit with binaryjs, but it seems to be a lot slower (at least factor 5) than the current formdata method, apparently because the client is heavily cpu limited while uploading. Not really an alternative.

One way I could see this work is by mixing binary and string types on the socket:

ws.send(JSON.stringify({path || filename, type}));
ws.send(blob);
ws.send(JSON.stringify({path || filename, type}));
ws.send(blob);

To get the blob, we need to use a FileReader, which I'm not sure how it would perform on big file trees.

Owner

silverwind commented Mar 31, 2015

Probably not worth the trouble right now. We'd loose browser compat and speed by doing this.

One planned improvement I have in mind is moving the uploading to a worker process. That should avoid the browser hangs when uploading big trees. Main blocker here is Firefox, which will get FormData in workers in 39.

@silverwind silverwind closed this Mar 31, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment