How I fixed a major latency issue in RuneScape’s game client

Note: Whenever I mention RuneScape in this post, what I really mean is Old School RuneScape, a retro throwback of the game that is still being developed. I just don’t want to keep typing that or use the slightly obscure acronym, OSRS.

For those of you that don’t know, RuneScape is (was?) one of the most popular MMORPG’s in the world. The game basically revolves around some relatively unknown character, who, through some odd sequence of events, repeatedly saves the fictional world of Gielinor.

Along the way, players perform mind-numbing grinds to advance from level 1-99 in 23 different skills (woodcutting, mining, etc). Most of these grinds take around 200-400 hours. But, as any r/WallStreetBets observer knows, people like to see number go up.

The average RuneScape player, probably.

If memory serves, I started playing RuneScape back in 2006. I had almost no idea what I was doing, but any teenage boy from that era knows that multiplayer, fantasy adventure games had quite a grip us back then.

Life eventually got in the way, but I returned to the game last year. RuneScape players like to joke that you never quit the game, just take breaks. That seemed to apply to me.

The game has changed a bit since I last played. Players wanted more of a challenge (think WoW raids), so the developers obliged.

The slight problem was that RuneScape isn’t really meant to be a super low-latency video game. After all, in the first version of the game, all you had to do was click a tree, wait a few seconds, then click again. As a result, the game operates on a clock, also known as a tick system, which operates at 600ms intervals. In short, if you click a tree, the action will be registered at the next 600ms interval (measured by the server).

I wanted to get into these new game features, primarily raids like Tombs of Amascut. And for that, I needed the ability to react to falling boulders/angry monkeys/explosions as quickly as possible. However, it soon became apparent that I was experiencing too much lag, despite the fact that my internet connection was quite good.

RuneLite (a popular RuneScape client) shows that there is a large delta between the server’s actual tick and my client’s observed tick. Only 63% of ticks are meeting a set threshold. (See plugin for details.)

After some internet sleuthing, I discovered I was not the only person with this problem. Someone on a StackOverflow-adjacent site reported latency spikes on their Mac, and attributed the issue to a power-saving measure. The top commenter seemed to agree.

From the top comment, the solution seemed to be straightforward. Keep the WiFi chipset busy so it would never go to sleep. But how?

Some users observed that while they were watching Twitch, the problem went away, and that makes sense. But I would rather have a solution that requires much less bandwidth. I ended up with something dead simple: continually ping the router as long as the game is running.

The most rudimentary way to do this is to simply use Terminal to ping the default gateway at a regular interval, in this case 200ms.

Problem solved.

However, I wanted to solve this problem for other users, too! And I didn’t want them to have to dig into the Terminal to determine their default gateway address and run a ping command.

Fortunately, RuneScape’s most popular client, RuneLite, is open source and has its own plugin framework. So, I wrote a plugin. The code is very simple. First, it uses Java to run a couple of CLI commands to grab the default gateway address.

Next, it pings the gateway, and gives up after a certain failure threshold.

That’s it. And thanks to RuneLite’s convenient plugin framework, all a user needs to do is click the plugin install button. Almost 400 users are actively using the plugin, which is very satisfying. Solving a problem for yourself is good, but solving the same problem for others is even better.

Thanks for reading. Always appreciate questions and comments. And to you nerds out there–Happy Scaping!


2 responses to “How I fixed a major latency issue in RuneScape’s game client”

  1. Thanks man, didn’t even realize I had this issue. Now I have an excuse for why I was bad at PvM.

    1. Jonathan Garelick Avatar
      Jonathan Garelick

      Ha! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *