web-socket-js icon indicating copy to clipboard operation
web-socket-js copied to clipboard

setting the overflow style on the body breaks flash socket

Open brettkiefer opened this issue 14 years ago • 5 comments

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.

brettkiefer avatar Apr 15 '11 13:04 brettkiefer

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.

gimite avatar Apr 20 '11 06:04 gimite

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!

bobbygrace avatar Apr 21 '11 15:04 bobbygrace

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! :)

scottschiller avatar Apr 22 '11 02:04 scottschiller

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!

brettkiefer avatar Apr 22 '11 03:04 brettkiefer

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.

gimite avatar Apr 22 '11 04:04 gimite