Animated GIFs Could Be The Answer To Visual Studio Code’s CPU-Heavy Cursor

Animated GIFs Could Be The Answer To Visual Studio Code’s CPU-Heavy Cursor
Image: Microsoft

You’d never suspect the humble cursor as a source of performance issues in your IDE, but that appears to be precisely the case with Microsoft’s Visual Studio Code, a cross-platform development environment built on Electron. A few days ago, a user reported the program consuming a large number of CPU cycles when idle and tracked it down to the blinking caret.

Fortunately, going from the report on Code’s GitHub repo, the problem appears limited to systems running OS X / macOS. Still, sapping 13 per cent of your CPU’s time (if the report is to be believed) is rather concerning.

Because Visual Studio Code’s source is right there for the tweaking, a workaround is easily implemented — turning off the cursor animation. Still, it’s 2017 — surely we can make editor cursors that don’t compromise your laptop’s battery life, right?

The cursor is implemented as a CSS-animated page element, so the issue might be with Electron, rather than Code. But let’s examine this further.

Turns out the solution might be to leverage the fact Code is based on Electron. Electron is basically a combination of a Chromium (yes, the core of Google’s browser, Chrome) frontend and a Node backend, facilitating cross-platform apps with rich user interfaces.

Now, there’s one thing browsers are very, very good at when it comes to animations and that’s the humble GIF. So, one suggested fix is to replace the cursor with an animated image. You can see an example here.

It’s one of a number of proposed solutions, with the issue unresolved at the time of writing. Still, I reckon the boffins at Microsoft — or someone in the open source community — will come up with something.

But my bet is on the GIF.

CPU usage even when idle (due to cursor rendering) [GitHub]

Log in to comment on this story!