gimite / web-socket-js

HTML5 Web Socket implementation powered by Flash
BSD 3-Clause "New" or "Revised" License
2.73k stars 489 forks source link

setting the overflow style on the body breaks flash socket #67

Open brettkiefer opened 13 years ago

brettkiefer commented 13 years ago

Repro

  1. Connect to a server via flash sockets in Firefox 4 on Windows 7 (and maybe elsewhere)
  2. Open Firebug
  3. Run document.body.setAttribute('style', 'overflow:auto');

. . . and for some reason, the socket disconnects.

gimite commented 13 years ago

It seems Flash object is reloaded on setting overflow attribute in Firefox for unknown reason. One workaround is to set the overflow attribute before loading WebSocketMain.swf. If you do that in window.onload or even before, it's probably fine. Or you can set

WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;

before loading web_socket.js and manually call WebSocket.__initialize(); after setting the attribute.

Please let me know if you find any better workaround.

bobbygrace commented 13 years ago

Thanks for the workaround! Our issue is that we have to set the overflow attribute after the flash socket has been initialized and sent messages. We're experimenting with using a top level div so we don't have to set overflow on the body. Thanks again!

scottschiller commented 13 years ago

A side note to this - setting display:none or switching position: between absolute/relative on the element, or its parents will cause the SWF to reload or partially restart, and that will break things (I've seen this with SoundManager 2, which uses JS/Flash extensively as well.) Firefox may also not actually start the SWF if wmode is set to transparent/opaque and the SWF is outside of the current view (ie., bottom of the page or off-screen.) Oh, fun! :)

brettkiefer commented 13 years ago

Okay, got it - 10-year-old bug: https://bugzilla.mozilla.org/show_bug.cgi?id=90268 Thank you for the workarounds; as Bobby says, we can't use 'em in this case, but I appreciate the help all the same!

gimite commented 13 years ago

This is definitely an issue (of Firefox, though), so I'll keep it open but label it as "will not fix". Thanks for the information.