sidorares / node-rfb2

rfb wire protocol client and server
MIT License
138 stars 27 forks source link

Are there instructions on how to use requestUpdate? #21

Closed Madd0g closed 7 years ago

Madd0g commented 7 years ago

I saw several people mentioning that they have to call requestUpdate in order to get new rect events. I'm also having this problem (client on OSX, server is x11vnc on Ubuntu).

I've seen multiple examples (in the linked repos from the readme) where people call it with setInterval or on every rect/raw event.

What's the proper (officially recommended) way of using it, why is it needed at all? Shouldn't the server push updates to the client without requesting them?

Also, if there's a requestUpdate in raw/rect event - wouldn't that create an infinite loop? For me it doesn't but I'm still wondering if it creates extra unneeded stress.

I tried using the linked rfbrecord and it only recorded the same frame until I added a requestUpdate everywhere.

Thanks

sidorares commented 7 years ago

I guess this is to give clients control over latency vs throughput. I usually do new requestUpdate as soon as I get update, but I can see scenarios where you might want to do it more or less often. For example if there is 2 seconds delay (but overall throughput is good), you could stream requestUpdate commands every 100ms. Or if data is very expensive you could do opposite: requestUpdate after each rectangle, but not more often than one every 5 sec.

I'm not sure if there is "officially recommended" way - it's just there for you to have control over it. As far as I know there is no way to tell server "just keep sending updates, as soon as anything on screen is changed, even one single pixel"

Madd0g commented 7 years ago

Interesting, I had no idea VNC worked like that.

How should I measure the throughput or delays? Is it the time between requestUpdate and the rect events?

Madd0g commented 7 years ago

Also, I always see rect events for the full resolution of the remote screen, what does the first parameter of requestUpdate (incremental) do? I thought I'd get smaller rects, but that's not what I see (with x11vnc server).

sidorares commented 7 years ago

yes, this is what it supposed to do. First update is full rectangle and subsequent updates are only as big as changed part of the screen

Madd0g commented 7 years ago

for me it doesn't work that way (maybe I'm using it wrong? or maybe the server doesn't support it?), I'm calling this function with the full signature function(incremental, x, y, width, height)

for example, if my server resolution is 1440x900, I always get rect events with { width: 1440, height: 900 } and I call the update with requestUpdate(true, 0, 0, 1440, 900).

sidorares commented 7 years ago

can you isolate vnc part of your code and post it here so I can test against x11vnc locally?

Madd0g commented 7 years ago

sorry, was my fault, figured out I was actually passing false when I thought I was passing true, completely different performance with incremental updates, wow.

sidorares commented 7 years ago

no problems, glad it's solved!