All posts

Remote control that keeps up with 4K

A 4K screen holds 33 MB of pixels. Here is how DeskGo sends only what changed, and how it went from 82 ms to 20 ms a frame.

A 3840 × 2160 screen holds about 33 MB of pixels. Sending that thirty times a second would need a gigabit link to itself. Remote control only feels usable when you stop thinking about frames and start thinking about changes.

Send only what changed

DeskGo divides the screen into tiles of 64 × 64 pixels and compares each one with the last frame it sent. A blinking cursor or a menu opening changes a handful of tiles, so a handful is all that goes over the network.

Each changed tile is compressed one of two ways:

  • Lossless (LZ4) for text, window edges and flat colours. These compress very well, and they have to stay exact to remain readable.
  • JPEG only for tiles that don’t compress losslessly, like photos, video and gradients. JPEG makes those many times smaller, which keeps scrolling a web page smooth over Wi-Fi.

JPEG is tried only when lossless compression does badly, so text is never blurred.

Faster capture

Our first version copied the screen with the classic Windows drawing API. On a 4K screen, capturing and encoding one frame took about 82 ms, which is barely 12 frames a second before anything was sent.

DeskGo now uses Windows Desktop Duplication, which hands over the finished image from the graphics card and says when nothing has changed. On our 4K test machine, capturing and encoding a frame dropped to about 20 ms. Where Desktop Duplication isn’t available, DeskGo switches back to the old method, and it tries again every few seconds.

The whole screen at once

Some moments change every tile: the first frame, switching monitors or maximising a window. When 16 or more tiles change, DeskGo encodes them on up to eight processor cores at once. A full 4K frame went from 115 ms to 13 ms.

Never falling behind

Speed is only half of it. If the computer sends frames faster than the network carries them, they queue up, and you end up watching the screen as it was several seconds ago. DeskGo allows at most two frames to be on their way at once, and the viewer acknowledges each one. On a slow link it sends fewer frames, each of them up to date, so what you see stays current. The frame rate is capped at 30 per second.

Keyboard and mouse

Keys are sent as Windows key codes, so shortcuts behave as they would at the other desk. The scroll wheel moves in the same steps Windows uses. If you click away from the DeskGo window, it releases every key you were holding, so a Ctrl or Shift is never left stuck down on the other computer.

Keep reading

More from the blog

Reach any computer, on any network

DeskGo used to find the other computer by asking around the local network. Now it can reach a computer wherever it is, with no router settings and no way for us to read what passes through.

Passwords are now just numbers

The one-time password is now eight digits instead of a mix of letters and digits. Here is why it got longer, and why it is still hard to guess.