Status
Not open for further replies.

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
So, my game is getting pretty big right now. I have quite a bit custom artwork and plugins. I've recently noticed that my game has started to stutter a bit every 10-15 seconds. I'm not able to figure out the cause. I've disabled plugins and enabled some... tested various combinations. The stuttering just seems to continue from time to time.

I've also tried doing tests in just one map. It stutters. I remove a few events. It still does it. However; I remove a few more and it seems to stop. I then enable some... it starts again, but then I remove different events... and it stops. It just doesn't appear to be anything in general and is completely random.

I looked online and found this response on another forum. I wanted to check on here and see if this is a good idea, might work, or if someone has a better/different suggestion before I went in and changed anything. I've been messing around with my game all day and cannot find the culprit. I didn't want to post an outside link (not sure if that's allowed), so here's what someone said to try:

Hey guys, I know this post is 5 years old, and I've had a similar problem with my game for YEARS, and I finally figured out today, with a clue from ??? (in this thread). It did indeed turn out to be Garbage Collection.

If you experience the micro-stutter it might help you as well. I go into the library file "pixi.js", and in it, there's a section to set global hard-coded variables for the rendering engine to override the defaults.

??? (on this Thread) was talking about the micro-stutter in RPG Maker MV games (lag spikes every 5-10 seconds) that cause it to feel like it "skips" or slight hang for a 10th of a second, every few steps or every few seconds. That he thought it was a problem with Pixi and how it handled rendering.

There is one attribute called "GC_MAX_CHECK_COUNT:" (Garbage Collector max check count) in Pixi.js around Line 21,239 for pixi.js - version 4.8.9.

To troubleshoot this, I set my game to Canvas mode temporarily, and the spikes went away, even though overall performance was lower (because using CPU instead of GPU in Canvas mode).

This led me to conclude (as ??? did) that it was something within Pixi.js and WebGL in the way that it renders everything, that was causing the spikes.

I went through editing the Global Defaults, setting memory buffer sizes, other crap, nothing worked, then I saw garbage collection "max checks" and I was like "hmmm that dude said something about garbage collection" and then I thought fewer checks would make it faster, so I set it to 1, instead of the default value of 600.

It make the stuttering really bad, really bad, but it was the same type of stutter.

Instead I set the value to be much larger, so it would be allowed to check 12000 times instead of 600, spikes went away. It was driving me nuts over years not being able to find it, turned out to be simple but not obvious. I hope this helps others who are experiencing this problem.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,261
Reaction score
9,691
First Language
German
Primarily Uses
RMMV
"Lag" is a very bad description because lag can have a dozen different causes.
and the only way to combat lag is to remove the specific cause(s) in your game.

guessing a fix will almost never help, because it is often pointed at the wrong cause.

IF you want to try that change, then you should do that in a backup, and only do so nearer to the finish of your game - otherwise you're risking too much sideeffects in my opinion.


that said, what you really should do is put some specific numbers out for us to check.
for example how big is one of those stuttering maps, and how many events are there?
Only then someone can decide if those numbers are enough to create regular lag, or if you did something wrong to create lag.

additionally try to give a better description than "it stutters" - what exactly happens?
a good description can help us to better pinpoint the cause.

for example everyone will tell you that you should include waits in parallel processes to reduce lag.
but if you include too many waits you'll get processing delays that look as if they are lag but are not.
and only with testing and a very good description someone can tell the difference if a map lags because the parallel processes have not enough waits, or if it is slowed because the parallel processes have too many waits.
 

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
@Andar Thanks for the reply. I'm not sure if this is enough, but feel free to request additional information, and I'm more than happy to provide :)

1653026286900.png
Here's a map that causes some stuttering/lag. 56 events and the map itself is 23x13.

I do have a couple of parallel process events running to move those events on top of another, but when I remove those events and have no parallel processes running on that map... the stuttering still happens.

I am curious if I have too many events on one map of that size. The reason I have so many is due to it being the player's hub. They craft, upgrade, listen to music, choose allies, etc. Here's a small video showing what it's doing. It isn't horrible... but I want to try and figure out what's causing it before I continue making my game larger.

Basically, I've tested it with all events and it stutters. I've removed a few here and there, keep testing, and eventually, it improves, but some maps have it and some don't. I did check to see if I have any common events running on a parallel process, and I don't. I'm basically starting my game as a "New Game" and no switches have activated or started anything at that point.

I have a video showing what it's doing, as well, but it's saved on my Dropbox and not sure if I can link that in here.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
44,740
Reaction score
15,873
First Language
English
Primarily Uses
RMMV

I've moved this thread to MV Support. Thank you.

 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,261
Reaction score
9,691
First Language
German
Primarily Uses
RMMV
If people talk about too many events causing lag, then they usually talk about several hundred events on maps of at least 100x100 tiles.
your map doesn't even come near those numbers, so it is something else.


one thing to know here is that a single badly designed parallel process can already lag the most modern computer to hell, while a dozen parallel processes with good designs do nothing.

based on that I'm currently guessing that you do something wrong with a lot of your events. Decorative events for example should never affect lag.

so what is the function for most of these events? there are a lot that have no sprites, what do they do?
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,667
Reaction score
2,758
First Language
EN
Primarily Uses
RMMZ
Feel free to link the video, Dropbox is OK. :kaohi:

Like Andar says, it's probably related to what the events are doing, so more details there could help~

Some more ideas/tips:
  1. Pressing F2 during play should show the framerate widget. That lets you check if you're seeing actual framerate drops (e.g. intense processing) or badly-timed events.

  2. Are you using any plugins? If so, could you share a screenshot of your Plugin Manager?

  3. Some event commands are "heavier" than others, e.g. Change Actor Images performs a full refresh on the player, so you shouldn't really use it every frame.

  4. If an event has no pages that meet their conditions, the event will simply not appear. There is no need to have a blank page 1 that doesn't do anything.

  5. 1~3 pages per event is no big deal, but 20 pages in 1 event implies you are doing things the hard way. Particularly if the page changes frequently. Generally you should only use separate pages when you want a persistent change (i.e. remains for the rest of the playthrough) in the event's appearance (image) and/or behaviour (priority, trigger, auto move, direction fix, etc). Otherwise you can use the Conditional Branch command in a single page to separate different responses.
 

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
@Andar & @caethyril

First off I can't thank you all enough for the help I've gotten from this community. You're all great! Anyway... yeah, my specialty is the creative side of game development. Story, mapping out the scenes, ideas, dialogue... but the more technical side of it... you can see that's where I lack experience LOL Getting better, though. I will say I use less event pages and more conditional branches (examples below)

So, I do have a lot of events running multiple things on that page, so I'm sure that's the issue, and you both gave me some really good suggestions. I'm going to try a few of those and keep messing around with my game. This now brings me to what my issue may be...

caethyril's #3. I change my actor's image a LOT because I'm doing quite a bit with different character animations based on their action. For example:

1. When he searches... he does a different animation.
2. When he turns on a light switch, TV, etc. He does a different animation.
3. When he upgrades... another character animation.

I also have an idle plugin where... if the character stands still... it swaps the character sheet out for a little bouncing animation. So, I pretty much have a character swap for everything you do in my game. Which makes me sad because it's super cute LOL Uhg. Here's the video showing all the different animations. Maybe I could event those swaps better...? I have tried testing my game without the idle animation, though... it I still get the stuttering, but it may be a combination of all the swaps, etc.

Dropbox Video *EDIT* I just watched this and the quality of the video doesn't really show the stuttering... you can see it a bit, though.

As for all the blank pages Andar asked about... you slowly start unlocking new objects in the living quarter. You can get a cat friend with various objects and toys for them. Cat bowls, bed, toy, etc. I have an event that randomly spawns the cat in different spots but I did that with quite a bit conditional branches (see below). I also have a couple events that block the player (just block events) since some of my artwork sits high on the sprite sheets, etc.

As for my framerate... yeah, that does appear to be an issue. I load my game up and hit F2... it immediately jumps up to 60fps. Or is this OK?

As for my plugin list:

If you scroll further down... I also included some screenshots of a few events:

1653070248214.png
1653070267320.png
1653070285160.png
Turning Shora's lighting off does help a bit. But the odd part... only in certain rooms. Like... if I turn Shora's lighting off in my main room in the video... it helps. However; Shora's lighting can be on in other rooms... no stuttering.

1653070845270.png
This event is basically moving to another location on the map. I am now realizing nothing is turning it off. I have a couple of these on the map.

1653070935272.png
1653070951620.png

This event checks your cat's happiness each time you enter the room and applies a buff depending on how well you're taking care of it.

1653071091724.png
All these events are simply block events with nothing in them. It's due to my artwork being so big, I had to add some Same as Character events to avoid the player from walking through the object. There's only one event in all this that triggers the work bench. No parallel process or anything here. Just a Player Action Button event.

1653071224370.png
These blank events would be the cat's food and water bowl, cat bed (some block events so players can't walk over the cat bed) and a couple parallel process events that are just moving over another event. Also... some are the cat's random spawn events that may show them eating, drinking, or laying in their bed.

An example of the food bowl eventing:

1653071306601.png
1653071325928.png

1653071753293.png
1653071764735.png
This is my search event. I swap my character out for another to do a search animation.

I'll also say that none of my events have more than 4 pages. I actually only have one event with four pages (no parallel or auto run processes in this event). The rest are 1-3 with more conditional branches being used. A couple parallel (which I showed above) and some auto run events that only trigger with certain switches and then I turn them off.

However; this issue does seem to happen in certain rooms. I've tested others... and the stuttering isn't happening, or is less. So it's not consistent from room-to-room... which I'm assuming is a good thing. I just need to find my bad eventing culprit, which I can't at this time.

I was thinking about commissioning someone for this very reason. Posting on here to have a "tester" with more knowledge on the technical side of things. I'd post that in the appropriate forum, of course. Or do you think that's going a bit too far? I'll mess around with it a bit first.
 
Last edited:

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,261
Reaction score
9,691
First Language
German
Primarily Uses
RMMV
all parallel process event should have wait commands in them.

the wait basically tells the computer "stop processing this event for x frames", which looks like a wait on regular trigger events, and results in the parallel process looping less often for PPs.

you don't have to set the location sixty times per second, no player is so fast. a wait(5) would reduce that to one set event location every tenth of a second and cost a lot less processing.
depending on what that event is, even a wait(10) or wait(15) might be good - but if the wait goes to high the location update might be too slow.
 

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
all parallel process event should have wait commands in them.

the wait basically tells the computer "stop processing this event for x frames", which looks like a wait on regular trigger events, and results in the parallel process looping less often for PPs.

you don't have to set the location sixty times per second, no player is so fast. a wait(5) would reduce that to one set event location every tenth of a second and cost a lot less processing.
depending on what that event is, even a wait(10) or wait(15) might be good - but if the wait goes to high the location update might be too slow.
Oh! Adding the wait to the parallel process did help. I wasn't actually aware of that, and your explanation was great. Thank you so much for that.

Stuttering is still happening a bit, but that did improve it. Fingers crossed I can improve my eventing further and stop it completely.

It's also so random. Like... I start my game up, and the stuttering isn't that bad. I then close the game and start it up again... the stutter is worse. Close. Open. Not that bad. It's my game. Going through random mood swings LOL That's the part that is confusing me. It isn't consistently bad or good.
 
Last edited:

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,667
Reaction score
2,758
First Language
EN
Primarily Uses
RMMZ
60 fps is the intended framerate for RMMV games, so that's OK. It's a time-averaged thing, that's why it "jumps up" when you open it for the first time.

For character swaps, it's recommended to keep the different sprites on the same spritesheet if possible. That ensures the sheet will be in memory when requested, so no time is wasted fetching it from disk.

Relatedly, you might want to try using a plugin like Community_Basic (present by default in new projects) to increase your game's image cache size. A larger cache means more images can be loaded into memory at the same time; smaller cache means less RAM usage, but more loading from disk (which might cause visual-only "lag").

And like Andar says, make sure to stop or pause any Parallel events when they aren't needed.

Hopefully you find a solution! :kaohi:
 

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
60 fps is the intended framerate for RMMV games, so that's OK. It's a time-averaged thing, that's why it "jumps up" when you open it for the first time.

For character swaps, it's recommended to keep the different sprites on the same spritesheet if possible. That ensures the sheet will be in memory when requested, so no time is wasted fetching it from disk.

Relatedly, you might want to try using a plugin like Community_Basic (present by default in new projects) to increase your game's image cache size. A larger cache means more images can be loaded into memory at the same time; smaller cache means less RAM usage, but more loading from disk (which might cause visual-only "lag").

And like Andar says, make sure to stop or pause any Parallel events when they aren't needed.

Hopefully you find a solution! :kaohi:
OK, upping my limit cache helped tremendously. I wasn't even familiar with that, so thank you!

I increased it to 100. Not sure if that'll cause issues in the long run, but I can always take it down to 50 if I notice anything.

Also, this may be overthinking it. Would a plugin that loads images at the start help? Not sure if I'm wording that correctly. Almost like a short loading screen when the game first starts? Or maybe community basic will do the trick.

Thanks again, everyone! :wub:wub:wub
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
36,261
Reaction score
9,691
First Language
German
Primarily Uses
RMMV
Would a plugin that loads images at the start help?
not at the start

there are preloader plugins, and they can help, but they depend on when the image is preloaded - and the start of the game is almost always the wrong time for that.

any preloader is always in conflict with the garbage collector. the gc is there to remove images from RAM that have not been used in longer times, so that the RAM/cache can be used for newer image files.

A preloader is used to remove loading delays (which is often called lag but has nothing to do with lag), and it works perfectly if it is triggered a few seconds before the picture is needed by the engine.
but loading at game start only fills up the RAM long before the pictures are needed, allowing the garbage collector to remove them as "too long unused" before they are actually needed, and forcing them to be reloaded when that time comes.

Preloader can help a lot when used correctly, and are either memory leaks or completely useless if not controlled to the correct timing.
 

AeroFunk80

Veteran
Veteran
Joined
Aug 25, 2016
Messages
263
Reaction score
143
First Language
English
Primarily Uses
RMMV
not at the start

there are preloader plugins, and they can help, but they depend on when the image is preloaded - and the start of the game is almost always the wrong time for that.

any preloader is always in conflict with the garbage collector. the gc is there to remove images from RAM that have not been used in longer times, so that the RAM/cache can be used for newer image files.

A preloader is used to remove loading delays (which is often called lag but has nothing to do with lag), and it works perfectly if it is triggered a few seconds before the picture is needed by the engine.
but loading at game start only fills up the RAM long before the pictures are needed, allowing the garbage collector to remove them as "too long unused" before they are actually needed, and forcing them to be reloaded when that time comes.

Preloader can help a lot when used correctly, and are either memory leaks or completely useless if not controlled to the correct timing.
So basically... I'm guessing I should stay away from this so I don't ruin my game further LOL That's me saying it... not you :elwink:

Thanks again. You both have been a great help and those suggestions fixed quite a bit of my issues. I'll have this thread closed and keep plugging away at my game. I'm almost to testing phase for my demo too! Getting very close :kaojoy:
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
3,667
Reaction score
2,758
First Language
EN
Primarily Uses
RMMZ

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Mixing different pixi filters over a picture. :MV3:

lumina_in_space.jpg

I don't know if my game dev skills are improving... But my waifu making ones sure are. :LZSwink:
Who wants to solve a riddle from my game?
"I prayed for her to lay down her worldly habit and accept the invitation to change her life forever." From lost to found. From past to present, From frown to smile. From the way people treat her as nothing but something to say wow about. From faithless to faithful. From something no one wants to something valuable, someone will respect and love. Thank you, Jesus.
Two new amazing plugins from @NhatNguyen! Footsteps & Stamina. Video on Twitter showcasing:

Forum statistics

Threads
123,098
Messages
1,153,963
Members
161,424
Latest member
kiamat
Top