[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IE 9 support - undefined errors in dynamically loaded scripts #205

Closed
gautamkhot opened this issue Oct 17, 2012 · 27 comments
Closed

IE 9 support - undefined errors in dynamically loaded scripts #205

gautamkhot opened this issue Oct 17, 2012 · 27 comments

Comments

@gautamkhot
Copy link

Does noVNC support access using IE9 out of the box? Is there anything specific that needs to be done to ensure IE9 compatibility?

Thanks in advance.
Gautam

@takaha
Copy link
Contributor
takaha commented Oct 17, 2012

I encountered some problems when using IE9 and I posted some patched to fix them.
You can try the patch from #202 if you want. noVNC will work fine on your IE9.

And you should know:

  • FlashPlayer is required.
  • you have to use IE9 in IE9 mode, not in IE7 compatibility mode. This is a trap.

@gautamkhot
Copy link
Author

Thanks, Takaha. I installed your fork and am noticing the same issue with IE9. It works fine with Chrome/Firefox, of course. Are there any clues that might be useful to track this down?

I did ensure that IE is running in IE9 mode.

@takaha
Copy link
Contributor
takaha commented Oct 17, 2012

I guess if you try restarting the proxy and reloading the noVNC on your browser again, it may work fine.

If not,

  • please run your noVNC with logging=debug.
  • please enable the F12 developer tools of IE9 and you can see messages on its console, which will include some error messages, and let me know the messages.

This site will help you to use the developer tools.
http://www.sitepoint.com/debug-faster-with-f12-developer-tools-in-internet-explorer-9/

@gautamkhot
Copy link
Author

Getting slightly further along:

[WebSocket] error communicating with Web Socket server at ws://:/websockify (SecurityError: Error #2048)

but this was followed by the following in a subsequent attempt.

LOG: Forcing uncached load of WebSocketMain.swf
LOG: >> RFB.constructor
LOG: >> Display.constructor
LOG: User Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
LOG: Browser: trident 6
LOG: No scaling support
LOG: Setting viewport to full display region
Data URI scheme cursor not supported
LOG: << Display.constructor
Using web-socket-js bridge. Flash version: 11
LOG: >> Keyboard.allKeysUp
LOG: << Keyboard.allKeysUp
LOG: No scaling support
LOG: Setting viewport to full display region
New state 'loaded', was 'disconnected'. Msg: noVNC ready: WebSockets emulation, canvas rendering
LOG: << RFB.constructor
LOG: >> Keyboard.allKeysUp
LOG: << Keyboard.allKeysUp
New state 'connect', was 'loaded'.
LOG: >> RFB.connect
LOG: connecting to ws://masked:port/websockify
LOG: << RFB.connect
LOG: >> Keyboard.allKeysUp
LOG: << Keyboard.allKeysUp
LOG: Closing WebSocket connection
New state 'failed', was 'connect'. Msg: Connect timeout
LOG: Clearing connect timer
LOG: >> WebSock.onclose
WebSocket on-close event
Received onclose while disconnected
LOG: << WebSock.onclose
LOG: >> Keyboard.allKeysUp
LOG: << Keyboard.allKeysUp
New state 'disconnected', was 'failed'.

@takaha
Copy link
Contributor
takaha commented Oct 17, 2012

This is another problem.
It looks like websockify also has a problem.

By the way, is ws://:/websockify is the right spell?

@gautamkhot
Copy link
Author

The spelling is right - I just masked the IP address out.

@takaha
Copy link
Contributor
takaha commented Oct 17, 2012

It seems like wss:// is correct.
But I'm not sure about it since I haven't ever used websockify.

By the way, does noVNC work without websockify?

@gautamkhot
Copy link
Author

What was missing was a socket policy file from port 843 - that did the trick.

Thanks for your fork and the time you spent on this ticket.

@kanaka
Copy link
Member
kanaka commented Oct 17, 2012

@gautamkhot @takaha I pushed an alternate fix for the script loading issue (6f4b1e4). Can you both test my implementation and confirm? I don't have easy access to IE 9. I'm going to re-open this bug until confirmation.

Thanks!

@kanaka kanaka reopened this Oct 17, 2012
@takaha
Copy link
Contributor
takaha commented Oct 18, 2012

This solved #199 but still sometimes causes #194.

It sometimes leaves "ReferenceError: swfobject is not defined" right after starting to load scripts. This will lead "ReferenceError: WebSocket is not defined" error when noVNC tries to connect.

The reason is that:

  • web-socket-js/web_socket.js refers "swtobject" defined in web-socket-js/swfobject.js.
  • it is not guaranteed that web-socket-js/swfobject.js is loaded and initialized before web-socket-js/web_socket.js refers "swtobject."

All scripts are loaded simultaneously and the completion order is indeterminate.

@kanaka
Copy link
Member
kanaka commented Oct 18, 2012

The two scripts might be fetched from the server at the same time, but two pieces of javascript code in the same execution context will never execute simultaneously (and you only get multiple execution contexts with frames or Web Workers). The problem is that IE 9 is executing the scripts sequentially but in a different order than they are appended to the DOM.

Here is a summary of the browser differences: http://ui.cognifide.com/slides/async-js/template/#26

There is a standardized solution to this (http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order) using async="false" but this isn't supported until IE 10. :-(

I may just end up importing LAB.js or possibly using document.write in the case of IE. I'll have to think about it a bit more.

@takaha
Copy link
Contributor
takaha commented Oct 18, 2012

I think the easiest workaround is to put the two script into one script, so you don't have to worry about the order anymore. My only concern is whether it is allowed to put codes under different licenses in one file.

I have another idea that you can divide the scripts into two groups or three, and noVNC loads the scripts in the first group and after that it starts to load the second group. In this case, web-socket-js/web_socket.js should be placed in the second group.

@kanaka
Copy link
Member
kanaka commented Oct 18, 2012

Those licenses are compatible, but the bigger issue is that all the code under web-socket-js comes from web-socket-js which is an external project maintained by a different person. I don't want to have to do post processing every time I update the version that I'm including. LABjs allows all the scripts to be loaded in parallel and still indicate the order that they should run in. But the minified version of LABjs is 5K and I'm a bit loathe to add yet another dependency. But for correctness sake I may still do that.

I might push a LABjs based branch for you to test later today to make sure it works correctly with recursive calls.

@kanaka
Copy link
Member
kanaka commented Oct 18, 2012

I just pushed an update that uses the load_scripts mechanism but adds defer to the script tag when using IE. And just for good measure (for FF and webkit) also set the async flag to false.

@gautamkhot and @takaha can you try my latest update with IE 9 and see if it fixes things for you?

@takaha
Copy link
Contributor
takaha commented Oct 19, 2012

Unfortunately it still causes "ReferenceError: swfobject is not defined" error.
It seems like IE9 ignores "script.async = false" and "script.defer = true".

IE9 is really weird :-(

@takaha
Copy link
Contributor
takaha commented Oct 19, 2012

I also tested it with vnc.html on IE10. which was still a preview version.

It said "HTML1524: Invalid DOCTYPE. vnc.html line 1 character 1".
The line "window. () { UI.load(); };" seems to have something wrong or IE10 is weirder.

@kanaka
Copy link
Member
kanaka commented Oct 19, 2012

I changed the doctype to the HTML5 standard one (I don't think the mobile one provides any benefits on modern mobile browsers). Please try IE 10 again.

@takaha
Copy link
Contributor
takaha commented Oct 22, 2012

Error "HTML1524: Invalid DOCTYPE" is fixed.
But it still generates another error "ReferenceError: RFB is not defined". This will happen on both vnc.htm and vnc_auto.html.

It looks like some symbols can't be referenced even when the script is already loaded in some situations.

It worked when I just tiried making noVNC wait for both window.onload and all the scripts loaded. But I'm not sure this is a right workaround.

@kanaka
Copy link
Member
kanaka commented Oct 23, 2012

I found a system that I can test IE 9 on and have adjusted the load_scripts utility. It works for me now with IE 9. @gautamkhot and @takaha can you please verify.

@takaha
Copy link
Contributor
takaha commented Oct 24, 2012

Great job! noVNC works fine with IE9.

But I noticed something weird happened with IE10. window.onscriptsload() was called twice somehow and I investigated it a bit.

It looks script objects sometimes generate duplicated 'complete' events. The second event is issued to invoke the onreadystatechange handler even when the handler is already set to null. It seems deleting the handler won't work for IE10 as we expect. I think you need to find another trick to avoid duplicated events.

But I wonder why IE10 generates duplicate events though.

@gautamkhot
Copy link
Author

I will try this today - sorry, have been a little distracted during the
last week with other work stuff. Will confirm my testing later today, India
time. Thanks!

On Wed, Oct 24, 2012 at 8:30 AM, Hirokazu Takahashi <
notifications@github.com> wrote:

Great job. noVNC works fine with IE9.

But something weird happened with IE10. window.onscriptsload() was called
twice somehow and I investigated it a bit.

It looks script objects sometimes generate duplicated 'complete' events.
The second event is issued even though the onreadystatechange handler is
already null. It seems too late to delete the handler for IE10. You need to
find another way to avoid duplicated events.


Reply to this email directly or view it on GitHubhttps://github.com//issues/205#issuecomment-9726192.

@kanaka
Copy link
Member
kanaka commented Nov 1, 2012

@takaha, I just pushed a change that will only fire onscriptsload when it has actually removed the last script. It could still fail if IE10 is sending a complete for a script even before it has executed but lets hope it's not that broken.

@gautamkhot any test results?

@takaha
Copy link
Contributor
takaha commented Nov 2, 2012

The last noVNC worked fine with IE10.

Thanks!

@kanaka
Copy link
Member
kanaka commented Nov 2, 2012

Great! I'm closing this bug. However, @gautamkhot I would still be interested in hearing your results once you get the chance.

Thanks for your help @takaha and @gautamkhot in tracking this down and testing.

@kanaka kanaka closed this as completed Nov 2, 2012
@takaha
Copy link
Contributor
takaha commented Nov 8, 2012

I just realized Opera also has the scripts load ordering problem. noVNC on Opera 12.02 caused a similar problem.
I think Opera should use the same path as IE does. But it won't be a big issue since Opera 12.10 won't cause any trouble since it has enabled native WebSocket.

@kanaka
Copy link
Member
kanaka commented Nov 8, 2012

@takaha I don't see the issue under Linux with Opera 12.02 (both vnc.html and vnc_auto.html work fine). You're getting "ReferenceError: swfobject is not defined"?

@takaha
Copy link
Contributor
takaha commented Nov 12, 2012

It did happen with Opera 12.02 for Windows and I saw "ReferenceError: WebSocket is not defined."
I think there was "ReferenceError: swfobject is not defined" before that, but I'm sorry I hadn't checked that.

I can get the Opera downgraded and reproduce the problem again if you want.

mightypenguin pushed a commit to mightypenguin/noVNC that referenced this issue Dec 11, 2013
Related to issue: novnc#205

Split out the function to load a single script to Util.load_script.

In order to get sequential load, when on IE set the script defer flag.
It is currently working on webkit and firefox but just in case also
set the script.async flag to make sure that scripts execute in the
order they are added. Scripts should still load in parallel.
mightypenguin pushed a commit to mightypenguin/noVNC that referenced this issue Dec 11, 2013
Use a mechanism described here to serialize the execution of scripts
under IE: http://wiki.whatwg.org/wiki/Dynamic_Script_Execution_Order
Basically, we set the src attribute but do not append the script to
the body/head until after readyState is "loaded". Unfortunately, Opera
uses readyState but in a different way (always "loaded" for both load
and execution).

This is related to (and hopefully fixes) these issues:
novnc#194,
novnc#205,
novnc#208.
mightypenguin pushed a commit to mightypenguin/noVNC that referenced this issue Dec 11, 2013
Related to issue: novnc#205

Split out the function to load a single script to Util.load_script.

In order to get sequential load, when on IE set the script defer flag.
It is currently working on webkit and firefox but just in case also
set the script.async flag to make sure that scripts execute in the
order they are added. Scripts should still load in parallel.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants