nx10 / httpgd

Asynchronous http server graphics device for R.
https://nx10.github.io/httpgd
GNU General Public License v2.0
390 stars 19 forks source link

More than 1-sec delay on live page when plot is updated #2

Closed renkun-ken closed 4 years ago

renkun-ken commented 4 years ago

I'm using the following code to test:

httpgd::httpgd()
plot(rnorm(100), main = "title")
abline(h = 0, col = "red")

When the first plot is called, the webpage is updated roughly more than 1 second later. And the same occurs with the abline call. I'm wondering if it is possible that the live page updates in a more responsive manner?

renkun-ken commented 4 years ago

Looks the current check interval specified at https://github.com/nx10/httpgd/blob/master/inst/www/index.html#L63 is too large. I tried 50 and it is very responsive now and I don't observe noteable difference of resource consumption.

Does it make sense to change this value to a much lower value than 1500 to make it responsive?

nx10 commented 4 years ago

I am currently working on implementing websockets to push changes as soon as they occur from the server to the client. This should lower resource consumption and eliminate any delay.

renkun-ken commented 4 years ago

I'm not sure if websockets could work in VSCode WebView especially in a remote development environment due to port forwarding not working for websockets (see https://github.com/microsoft/vscode/issues/74085).

nx10 commented 4 years ago

Good to know. I will keep a way to check for events in an interval via HTTP for environments where websockets are not available.

renkun-ken commented 4 years ago

With the latest commit, the check interval 500 looks much more reponsive now. Thanks!