clementfarabet / gfx.js

A graphics backend for the browser (with a Torch7 client).
MIT License
125 stars 35 forks source link

Nondeterministic load issue results in null document.body used by tty.js on slow connections #23

Open judnich opened 10 years ago

judnich commented 10 years ago

When SSH tunneling into my linux box from my laptop outside of my local network, I noticed gfx.js loaded but never displayed anything -- clicking the "+Term" button did nothing, and no images were rendered as they should from my Torch scripts. Being able to log in from less-than-gigabit connections is pretty important to check up on machine learning experiments etc. running on a server, and gfx.js is a amazingly nice way to visualize plots, images, etc.

Debugging in Chrome lead to the realization that a null document.body was being cached in a local variable in tty.js, despite this code only being executed via "on(document, 'load', load);".

The following ugly hack patches the problem for now: In tty.js, change "setTimeout(load, 200);" to "setTimeout(load, 2000);" Anything lower than 2000 doesn't work from slow connections, but it really depends on your connection speed. Obviously, having a critical dependency on network connection speed is a bug. The existence of that setTimeout() seems like it was a hack in the first place in tty.js.

I should add that I briefly looked at the tty.js source from the original repository, and it seems all this code has changed, so perhaps this has since been fixed by tty.js. In any case, a simple replace of tty.js with the latest from the tty.js repo didn't work, so I assume theres's some customization that would need to be updated.

soumith commented 10 years ago

i'm not sure if anyone else uses gfx this way, but I am also one of the "remote" users. This is why I also added configurable https support as well.

I should add that I briefly looked at the tty.js source from the original repository, and it seems all this code has changed, so perhaps this has since been fixed by tty.js.

Unfortunately no, tty.js is a pretty dead project, and we are in sync with their latest version (and I added in some patches that fixed a host of issues which were not getting pulled into tty.js).

The following ugly hack patches the problem for now:

I am working on a more resilient and robust frontend similar to gfx, but adds a mosh-like state-synchronization that should make it work regardless of the connection quality, will post here once that is done.

soumith commented 10 years ago

added this fix in #24