doppio icon indicating copy to clipboard operation
doppio copied to clipboard

WebSocket Flash Fallback Fails

Open jvilk opened this issue 11 years ago • 16 comments

In older browsers without WebSockets, WebSockify attempts to load a Flash file as a polyfill.

But it doesn't load properly.

WebSockify uses its own load_scripts function to dynamically pull in polyfills at runtime, which clashes with RequireJS. In addition, it requires access to the SWF file in the build directory at a particular location relative to the WebSockify JavaScript file.

Proposed solution:

  • Do not bundle WebSockify with Doppio. If a user wants WebSockify, they should drop it into the doppio.js directory and we will 'do the right thing'.

jvilk avatar Sep 18 '13 15:09 jvilk

Or maybe they should:

  • Drop it into the doppio.js directory.
  • Include it into their page.

Then we don't have to do anything but detect the WebSock object provided by WebSockify.

jvilk avatar Sep 18 '13 15:09 jvilk

I'm in favor of the latter, perhaps with a configurable WebSock parameter somewhere that defaults to null. I'm not a huge fan of changing behavior based on whether an arbitrary value is defined with the name WebSock.

perimosocordiae avatar Sep 18 '13 16:09 perimosocordiae

How else should we test for WebSockify? Testing for global objects is how you detect whether or not things are present in the browser world.

jvilk avatar Sep 18 '13 18:09 jvilk

Unless you mean check once and set a bool. I'm all for that.

jvilk avatar Sep 18 '13 18:09 jvilk

I mean we can pass in the WebSock object to some constructor somewhere, instead of testing for its presence.

perimosocordiae avatar Sep 18 '13 18:09 perimosocordiae

Ah, gotcha. Probably during JVM instantiation or something. I'll consider it!

jvilk avatar Sep 18 '13 18:09 jvilk

The change I made successfully defines the Websock object in WebSocket-enabled and non-WebSocket-enabled browsers.

The next step is to:

  • Make Websock part of the constructor for e.g. JVM/runtime state.
  • Ensure networking programs have a relevant error message when networking isn't available.

jvilk avatar Sep 18 '13 23:09 jvilk

@jvilk

I am trying to run a Java program using some classes in java.net package ( mainly class java.net.URL and java.net.URLClassLoader ) in doppiojvm, i got some error.

Uncaught ReferenceError: Websock is not defined
  java_net_PlainSocketImpl.socketCreate(Z)V  @ java_net.ts:169
  Method.code  @ methods.ts:293
  NativeStackFrame.run  @ threading.ts:295
  JVMThread.run  @ threading.ts:671
  (anonymous function) @ threadpool.ts:83
  i @ main.ts:158

I guess it's related to this issue, and if i should do something when doppio init.

hanyuei avatar Jan 21 '16 04:01 hanyuei

@CoderRooftrellen Just created a related issue: https://github.com/plasma-umass/doppio/issues/418

jimfb avatar Jan 21 '16 18:01 jimfb

I haven't tested the net code in awhile, so it could be broken. I'll take a look once I fix the build issues.

jvilk avatar Jan 23 '16 00:01 jvilk

@jvilk Thanks.

hanyuei avatar Jan 23 '16 03:01 hanyuei

I ran out of time today since the build issues took awhile. It's on my todo list for tomorrow.

jvilk avatar Jan 23 '16 04:01 jvilk

@CoderRooftrellen For the specific issue you mention "Websock is not defined", the solution I think is to include the script from doppio/vendor/websockify/websock.js on the page, before starting the doppio-jvm.

@jvilk However, after doing that, I see another error:

Uncaught Error: Assertion failed: Int value is out of bounds: 4026531841
assert @ assert.ts:8
validateReturnValue @ threading.ts:1231
JVMThread.asyncReturn @ threading.ts:1035
Opcodes._return_32 @ opcodes.ts:1153
BytecodeStackFrame.run @ threading.ts:254
JVMThread.run @ threading.ts:800
(anonymous function) @ threadpool.ts:83
i @ browserfs.min.js:8

hrj avatar Apr 22 '16 18:04 hrj

@hrj flatThrwoableToJs is spelled wrong, did you mean flatThrowableToJs? Also, That's not doppio code :P.

jimfb avatar Apr 22 '16 23:04 jimfb

@jimfb Hawkeye! Yeah, the second error was not relevant to doppio. I have edited it out.

hrj avatar Apr 23 '16 04:04 hrj

I'm working on this in #462.

jvilk avatar Jun 06 '16 22:06 jvilk