-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Comments
I encountered some problems when using IE9 and I posted some patched to fix them. And you should know:
|
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. |
I guess if you try restarting the proxy and reloading the noVNC on your browser again, it may work fine. If not,
This site will help you to use the developer tools. |
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 |
This is another problem. By the way, is ws://:/websockify is the right spell? |
The spelling is right - I just masked the IP address out. |
It seems like wss:// is correct. By the way, does noVNC work without websockify? |
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. |
@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! |
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:
All scripts are loaded simultaneously and the completion order is indeterminate. |
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. |
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. |
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. |
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? |
Unfortunately it still causes "ReferenceError: swfobject is not defined" error. IE9 is really weird :-( |
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". |
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. |
Error "HTML1524: Invalid DOCTYPE" is fixed. 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. |
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. |
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. |
I will try this today - sorry, have been a little distracted during the On Wed, Oct 24, 2012 at 8:30 AM, Hirokazu Takahashi <
|
@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? |
The last noVNC worked fine with IE10. Thanks! |
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. |
I just realized Opera also has the scripts load ordering problem. noVNC on Opera 12.02 caused a similar problem. |
@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"? |
It did happen with Opera 12.02 for Windows and I saw "ReferenceError: WebSocket is not defined." I can get the Opera downgraded and reproduce the problem again if you want. |
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.
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.
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.
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
The text was updated successfully, but these errors were encountered: