How to Fix Game Lag in Android?

My game has received a lot of player returns lag since its launch. How can I fix it?

This is my game:
google play
Lol there is no general fix to "Lag". Lag can occur for different reasons at different places in different games. Lag can be caused by:
  1. Insufficient hardware.
  2. Non-optimized code.
  3. Caching problems.
  4. etc.
If the issue is simply hardware, then nothing you can do. Just think about it, Final Fantasy 15 cannot run on a lot of machine and necessitates a minimum of processing power. Although the power required to run a RPG Maker game is much less, it's the same principle. If the phone isn't powerful enough, it will lag.

As for optimization problem, then you should be able to fix it, but it will not be easy. Check for the number of parallel processes, the size of your maps, the number of events, etc. A map of more than 50x50 tiles will usually lag on mobile. It could also be due to a plugin and how the logic is coded. Sometimes the programmer hasn't coded the most lightweight way to execute a certain function. For that, you'll need to be a programmer to fix unfortunately.

Caching is the game loading assets into memory to be used by the CPU. If the memory is full, for example due to a memory leak, or simply due to the fact that you're loading too many stuff into memory and exceeding capacity (remember, although most computers have 8GB or even 16GB of ram, phones can somtime have 2GB or 3GB of ram in total, and the OS can take up more than half of that).

So to conclude, there's not one way only that lag occurs, and we can't know for sure what is the cause of lag in your game.
Caching is the game loading assets into memory to be used by the CPU. If the memory is full, for example due to a memory leak, or simply due to the fact that you're loading too many stuff into memory and exceeding capacity (remember, although most computers have 8GB or even 16GB of ram, phones can somtime have 2GB or 3GB of ram in total, and the OS can take up more than half of that).

Is there any way I can check the operation of the game on the phone?
For example, check if the memory is full?
On mobile right now so I can't give you an in depth reply, but for one: the lighting plugin. This will absolutely slow down the game a ton on any device that isn't mid-high end ($200+ at minimum). In general no low-end or cheap device can run RPGM games no matter what, so if you don't set your game up so those users can't download it, they will do so and then leave bad reviews.

I've written about it on my website (jkgames.net) if you're interested in learning more about mobile performance for MV games.
Code:
window.nw.performance.memory

This little line of code should access the cache usage, which you can write in any plugin or directly into the console. You can also check it directly into the console (F8 or F12) when you playtest it on your computer. I'm not sure it is possible to access the console on mobile or not (I have never tried, but the console isn't there in any deployed version by default that's for sure).
What mostly causes lag is faulty plugins, bad eventing, lots of parallel events and big world map especially if you do complex parallax mapping with layers, etc. My own game which is pretty complex and runs ~100 plugins with animated busts etc. works pretty well (not perfectly, but good) on my $200 phone which I brought 2 years ago, but it plays more like VN novel/manager game.
The worst performance killers from my experience are parallax mapping and combat. And of course plugins. Some even very popular ones are not very well made and I would say highly hazardous for the projects since they cause memory leaks and game crashes. You can test on android studio turning on/off some of them to see if it changes performance.

As it was mentioned, I read that lightning plugins slow down the performance a lot. I would test performance starting that.
Out of curiosity, has anyone tried a large map that's mostly empty space? My game has a 100x100 map, but most of it is just the Night Sky parallax background (the setting is outer space). Not sure if this would cause significant lag?
Also, I think there was an issue of Intense Lag related to a Water Tileset, Not sure if they fixed it in the Latest version. I have a Japanese Plugin to fix this (Plugin is in Japanese), Got it for free when i got my FSM - Woods & Cave DLC.
While there are many things that will contribute to lag, one major thing you can do for a game you plan on releasing on Android is minimize your file sizes. Lower bitrate audio, lower the quality a bit on resources... hum.. like in Photoshop, when saving, there is a save for web option that has specific settings that doesn't really lower the visible quality but reduces the file sizes significantly. phones often run with minimal ram available. I would expect between 2 and 4 GB of ram to be the average. not everyone is rocking a flagship 8 - 12 GB $1000 phone.

By minimizing these filesizes things in general should load faster, and by impacting ram less, some lag caused by such things can be mitigated. I do however recommend testing on a variety of devices before publishing to any platform as a general rule. I test on my note 9, an LG Stylo 2, and an older HTC phone. if it at least runs good on the LG and my note I am happy. if I can manage it running great on my old HTC as well thats great and means I could have the broadest userbase.

the default resources have reduced file size versions available in your dlc folder if your a steam user. you will have to do this on your own for dlc or custom resources of course.
@Failivrin that would depend on the picture used in the parallax, because that would be the most resource-intense part of such a map. A small but repeating night sky would be no problem, a larger one could cause lag.

@Black Pagan that was not a tileset, it was the way water was animated in the regular tilesets of version 1.0 of the engine. was solved with one of the updates years ago (current version is 1.6.2 after all).

In general, what people often forget is that lag is additive and that all devices have some reserves before lag becomes visible. The last changes before lag becomes detectable aren't always the biggest problem, they might just have been the minor additive lag that pushed the device beyond its reserves.

That said, in most mobiles those reserves are low to non-existant, making anything that creates lag directly important.
Basically to get a game to work on mobile without lag, you'll have to keep the deployment in mind from the get-go and consider everything you add to your game from a perspective of lag if you want to deploy to mobile.

Some Lighting plugins have been known to create lag in computer-deployments and even the best of them are a strain on the resources, so they are not to be advised for mobile use. Same goes for large parallaxes.
However what can be used is parallax maps that are limited to screen size. Yes, that is rather small for maps (especially as you should keep this near default screen sizes, not 4K-screens) but it can be handled - after all most mobiles can display pictures to their screens.
But you can't go much farther than that because the RAM-requirements for pictures go really up with the size, and for parallax mapping you usually need to display two or three pictures at the same time (ground and top and sometimes shadows, and again mobiles are only intended to display one picture at a time under regular use, which is why that strains RAM as well).
Code:
window.nw.performance.memory

This little line of code should access the cache usage, which you can write in any plugin or directly into the console. You can also check it directly into the console (F8 or F12) when you playtest it on your computer. I'm not sure it is possible to access the console on mobile or not (I have never tried, but the console isn't there in any deployed version by default that's for sure).
This code didn't work, and showed errors
"Uncaught TypeError: Cannot read property 'memory' of undefined"
@aroha Try this instead:

Code:
process.memoryUsage()
@aroha Try this instead:

Code:
process.memoryUsage()
{rss: 376160256, heapTotal: 48451584, heapUsed: 35830748, external: 271778074}
What does it mean?
@aroha It's the number of bytes used in memory.

  • rss stands for Resident Set Size, it is the total memory allocated for the process execution
  • heapTotal is the total size of the allocated heap
  • heapUsed is the actual memory used during the execution of our process
  • external is, according to the documentation, the memory used by “C++ objects bound to JavaScript objects managed by V8”

Yours seem a bit high compared to my projects, but it shouldn't be too problematic I think. But perhaps on mobile it might put a strain, although I have no idea since I'm not much of a mobile guy. Your lag is probably due to CPU usage more than memory usage.
My game has received a lot of player returns lag since its launch. How can I fix it?

This is my game:
google play
Not related to your question... but how did you manage to put 340MB apk size ng Androod store? Thanks.
Not related to your question... but how did you manage to put 340MB apk size ng Androod store? Thanks.
Turn off the lightning plugin and other stuff that eats performance. Usually, mobiles are not as fast as desktop PC and MV isn't known for good performance despite it's advertised as "For mobiles".
Big maps 50x50+, events, and plugins are performance killers, especially true on lower-end PC/laptops/mobile devices.
Also, avoid using too many parallel events, especially without the "wait" command as they will add lag significantly (depending on how your event them).
Other than that, nothing can't be done as the engine itself performs poorly.
Not related to your question... but how did you manage to put 340MB apk size ng Androod store? Thanks.
Reduce the size of pictures and music as much as possible, and upload them as obb
Reduce the size of pictures and music as much as possible, and upload them as obb
Thanks! The difficult part is converting it to OBB? How did you managed it? Thanks in advance.
Thanks! The difficult part is converting it to OBB? How did you managed it? Thanks in advance.
Maybe you can try this

Original thread: https://forums.rpgmakerweb.com/threads/how-to-fix-game-lag-in-android.116402/