Fix: IE9 leaves "ReferenceError: RFB is not defined" #201

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
2 participants
Contributor

takaha commented Oct 15, 2012

This patch gives a workaround for kanaka#199 and kanaka#194 .

noVNC also runs well on IE9 with the patch:

  • it is guaranteed that scripts are Initialized in register order.
  • noVNC starts its service when catching a NoVnc.onload event, which is fired when all scripts are loaded and initialized.

This patch makes all script objects catch its onload event to track the status of loading scripts. When it detects the completion of loading all of them, it starts to call the initialization routines of the scripts in register order. If there is a script named ABC.js and it depends on objects defined in other scripts to initialize itself, you should move this part into a initialization routine named _init_ABC(). This function is guaranteed to be called after the scripts it depends has been initialized.

There is a chance some scripts happen to require loading other scripts from their initialization routines. In this case, noVNC will wait for the completion of loading these scripts again and restart invoking initialization routines.

Once it detects all scripts are initialized, it fires a NoVnc.onload event.

@takaha takaha scripts' initialization control.
 - Initalize scripts in register order.
 - Fire a NoVnc.onload event when all scripts are loaded and initialized.
 - noVNC starts its service when catching a NoVnc.onload event.
d7dbc42
Contributor

takaha commented Oct 16, 2012

There will be another workaround that you can serialize the scripts and load them one by one to keep the initialization order. This way may be a bit slow but it will work fine.

Owner

kanaka commented Oct 17, 2012

This should be fixed using a different approach in: 6f4b1e4

kanaka closed this Oct 18, 2012

@mightypenguin mightypenguin pushed a commit to mightypenguin/noVNC that referenced this pull request Dec 11, 2013

@kanaka kanaka Refactor dynamic script loading. Add util.js:load_scripts()
Related to issue/pulls:
novnc#194
novnc#201
novnc#202

In IE9, the window.onload event can fire before dynamically loaded
scripts have finished loading. This can result in either WebSocket (in
the case of vnc_auto.html) or RFB (in the case of vnc.html) not being
defined at the point when window.onload is called.

- Move the load_scripts routine from vnc.js to util.js (so that
  websockify can use it too). Also, refactor to work when load_scripts
  is called by a script that itself uses load_scripts. When the whole
  chain of dynamically loaded scripts is finished then call
  window.onscriptsload. Use this mechanism in all the places that
  depend on dynamic loading of scripts: vnc.html, vnc_auto.html,
  websock.js, tests/vnc_playback.html, and tests/vnc_perf.html.

- Use the new window.onscriptsload handler instead of window.onload.

- Remove include/start.js and do the script loading and startup event
  handling in include/ui.js instead.
6f4b1e4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment