plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.17k stars 176 forks source link

WebSocket Flash Fallback Fails #258

Open jvilk opened 11 years ago

jvilk commented 11 years ago

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:

jvilk commented 11 years ago

Or maybe they should:

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

perimosocordiae commented 11 years ago

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.

jvilk commented 11 years ago

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 commented 11 years ago

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

perimosocordiae commented 11 years ago

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

jvilk commented 11 years ago

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

jvilk commented 11 years ago

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

The next step is to:

hanyuei commented 8 years ago

@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.

jimfb commented 8 years ago

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

jvilk commented 8 years ago

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.

hanyuei commented 8 years ago

@jvilk Thanks.

jvilk commented 8 years ago

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

hrj commented 8 years ago

@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
jimfb commented 8 years ago

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

hrj commented 8 years ago

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

jvilk commented 8 years ago

I'm working on this in #462.