mozilla / makedrive

[RETIRED] Webmaker Filesystem
Mozilla Public License 2.0
351 stars 33 forks source link

Android & Websockets #448

Open thisandagain opened 9 years ago

thisandagain commented 9 years ago

Within webviews on Android < 4.4 we hit an issue with makedrive in that WebSockets are not supported. Specifically, we get a fatal exception on line 10 of client-ws.js:

global.WebSocket.prototype.on = global.WebSocket.prototype.on || function(event, listener) {
10-21 21:10:43.459: E/Web Console(18005): Uncaught TypeError: Cannot read property 'prototype' of undefined

I realize that it may not be possible to resolve this in its entirety, but it could be helpful to have makedrive return an error to the client for handling vs. throwing when WebSocket is undefined.

alicoding commented 9 years ago

So, when you mentioned Webview is that the default browser app from Android on Kitkat correct? The reason I asked here is that it might not be possible to solve this using our current Websocket impl, but I believe if anyone using Chrome or Firefox browser app will be able to run MakeDrive with Websocket no problem.

alicoding commented 9 years ago

@thisandagain can you comment on the conversation we had about socket.io and sockjs again? I can't recall about this.

thisandagain commented 9 years ago

In Android prior to version 4.4, Websockets are not supported in either the Webview class or in the default browser that ships with the OS. Because of this, we'll want to look at using a library that provides a polyfill. I've worked with a bunch of these in the past (like socket.io and sockjs) but don't have any strong recommendations particularly given that socket.io was just recently redesigned.

One thing that we might want to look at is Primus which isn't a websocket polyfill / library per-se as much as it is an abstraction to help prevent against lock-in. This could be particularly helpful with testing!

See: https://medium.com/@denizozger/finding-the-right-node-js-websocket-implementation-b63bfca0539

humphd commented 9 years ago

Interesting discussion of socket.io + FFOS 2.0 + Flame https://groups.google.com/forum/#!topic/mozilla.dev.platform/X7fGhVL_NrI