tutorials game, mobile
Optimizing Mobile Game Performance: RuneScape
RuneScape is a hugely popular MMO, now in its 20th year, which has recently been ported from desktop PC to mobile platforms. The Galaxy GameDev team were involved from an early stage in development, profiling the game and providing optimisation recommendations for the development team.
While we made a number of suggestions over the time we supported the game, the most significant was the recommendation to move rendering API calls onto a dedicated render thread (a.k.a deferred rendering). This aligned with the work the RuneScape team were already doing to move to a separate thread for rendering. It is not uncommon for PC games to rely on a single thread which handles the main game loop and also the rendering, but this can be a limiting factor for framerate on mobile; the CPU was taking much longer to submit a frame than the GPU was taking to render it.
The major difference between a desktop PC and a mobile device is the power requirements for each. A desktop PC can be plugged into the mains and draw a large amount of power, 500W plus for gaming PCs, and can use large fans to keep cool. A mobile device normally relies on a small battery, and needs to be comfortable to hold, restricting how hot it can get. For long battery life and comfortable temperature, the device should use around 3-4W of power.
This means that mobile CPUs cannot reach the high frequencies of a desktop CPU, making it hard to match the single-threaded performance. However, both desktop and mobile CPUs have had multiple CPU cores for some time, making it possible to spread the load across several cores.
The simplest architecture for breaking up a single threaded game is to create two threads, one for the main game and other systems, and one for rendering the scene. This is the approach that Jagex took with RuneScape for mobile and it made a big difference to performance: framerate more than doubled in some cases.
More complex architectures use job systems to split up certain CPU tasks such as physics and animation to be run on several cores in addition to having a separate render thread. This approach can be found in game engines such as UE4 and Unity.
It’s worth noting that even if your game is running at 60fps using a single thread it may still be beneficial to switch to multithreading. This is because there is not a linear relationship between clock frequency and power usage. By running everything on one core, that core will need to run at a higher frequency than if the work was spread across more cores, and that will cause higher power usage and battery drain. It may also cause the device to throttle the CPU to avoid overheating.
Stay in Touch with Galaxy GameDev
In addition to the many resources on this site, the Galaxy GameDev team is starting a new, quarterly newsletter focuesed on optimizing games for mobile devices. If you found this article interesting, please sign up for this newsletter. If you have questions about developing for Samsung Galaxy devices, please join us on the Samsung Developer Forum.