Game "lag" as file playtime increases.

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
Hello everybody. So, I've run into a bit of an issue with map lag that I was hoping someone might be able to help me with. At first, I thought it was my maps themselves that were laggy, but after doing some testing, I found that it was something else.
Attached, you will see a video that shows the difference in lag between a NEW GAME versus a loaded save file with 20+ hours of play time in it.
(Don't mind the poopy quality, my computer doesn't like running MV and OBS at the same time) - When I'm not recording, there is much less lag).

None of my maps lag when I playtest them on a brand new save file. and typically all run at a smooth 60 FPS. But, on save files that are 10-15+ hours into the game will begin to sway from 45-60 FPS, causing a sort of "stutter" when you move your character.

I have no parallel process events going on on the map OR in common events, so it's not that. I make sure to "dump" all variables that are no longer in use, just to make sure there are no excessively big numbers being stored in-game anywhere. Does anyone have any idea what might be causing this?

EDIT: I'm running MV v1.5.1 - all my plugins are up to date and in the correct order they need to be in (I've even turned off a lot of plugins to see if it changes anything, and the stutter steps persist). I've also used a lot of the instructions found on these forums to address lag, such as editing the "package.json" and making sure my drivers are all up to date and able to handle webGL, etc.
 
Last edited:

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
I've noticed the same thing with ACE, so it's something DEEP in the code that was not changed and only converted from Ruby to JavaScript. I get a little lag/choppiness where it jumps FPS like you mentioned if I go to a map with 20 hours playtime, but if I go to that map with 0 hours of playtime, completely smooth.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
31,365
Reaction score
7,675
First Language
German
Primarily Uses
RMMV
From that description you have a memory leak in your project.
If your project core (and not only the editor) is 1.5.2 then the memory leak has to be in one of your plugins - the last memory leaks in the default engine were removed with 1.5.0 rpg_core.js

So I suggest you give us a screenshot of your plugin manager - most likely we can't do anything but perhaps we see something that might help.

@bgillisp Ace was never improved as far as MV so it isn't surprizing that it still contains memory leaks - those are difficult to detect, but with 1.5.0 MV should be free of memory leaks in the core itself. Only the plugin programmers can remove memory leaks in their plugins however...
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
@Andar : A memory leak would make sense if you left it running all that time, but I think we're both talking about games that you play more naturally. Memory leak should not be an issue unless they use the worst saving algorithm in history.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
some object is saving batches of data and iterating through them at each ping.
and it looks like the more you play, the more data it saves.

I have such an object, that I made myself, and I made it with that flaw, and it caused the same problem: a skill reuse counter, which would store all skills with cooldown time after battle.
I solved the problem by not pinging the object at each frame, but rather every couple of in-game "hours", so the "advance hour" routine pings the object, subtracts the time from the cooldown, and removes those with less than 0 time, one time every couple of minutes.
constant pings to the same object would return results like "1 hour remaining" for every single ping (which I *don't* make) instead of "59:00 minutes", "58:59 minutes", "58:58 minutes" etc.
it's not a real-time feedback, so it shouldn't have a real-time update.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
Out of curiosity, would the variable tracking playtime be what could be causing this? Over time, the variables in rpg_objects would become increasingly large. I was digging through the js files and came across the following code, which seems to run every frame:
Game_System.prototype.playtimeText = function() {
var hour = Math.floor(this.playtime() / 60 / 60);
var min = Math.floor(this.playtime() / 60) % 60;
var sec = this.playtime() % 60;
return hour.padZero(2) + ':' + min.padZero(2) + ':' + sec.padZero(2);
};
I could see this being a culprit, because as playtime increases, so too do these variables tracking the playtime happening every frame.
 

gstv87

Veteran
Veteran
Joined
Oct 20, 2015
Messages
2,248
Reaction score
1,250
First Language
Spanish
Primarily Uses
RMVXA
IIRC, that's only accessed during saving, to display the play time on the save slot.
unless, an active plugin taps into that for some reason other than reading it one time.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
There is no difference between a newly-started game and a game you've just loaded from the save file, except the data you're beginning with. The amount of data should not really make a difference - it's what's done with it.

I initially thought you were referring to playing straight for X hours, and would have said it's because all your resources are still loaded into memory and not being unloaded. But if you're actually closing down the game between sessions, then continuing from a save file, all those resources would be reset.

A memory leak is similar - it gets worse the longer you play, but as soon as you end that session by closing the game and restarting, it's no longer an issue, until you've played for a long time again.

Neither of these problems would cause the game to lag the moment you load a 20+ hour save file.

As you progress through the game, your data (save file size) increases by default - you're getting more party members, getting more items, skills, etc. But I wouldn't expect those things to cause this kind of issue.

I'm guessing you have one or more plugins that add their own data, and they're either continuing to add data, or processing it in a way that's slowing things down.

For example, my own multi timer plugin looks at all the timers you have saved and decreases the amount of time remaining on each timer, on each frame. It also saves this in the save file. So if you accumulate a large number of timers and it's decreasing/checking every one on every frame, that would definitely impact performance more as you got further into the game. And that would be a constant impact, at least while you're on the map (and maybe in battle) - wouldn't matter what map you're on. In fact I might go revisit that plugin and change it to count seconds rather than frames.

A self-variables / self-switches plugin would have a similar effect, as every time the map is refreshed, every page of every event is checked, until the active page is determined. A self-variables / self-switches plugin would have additional tasks to perform when checking each page, so would make it take just a little bit longer.

There are probably other plugins that might contribute to lag, so maybe provide a list and see if anyone recognizes any that do.

And if you're using my multi timers, let me know and I'll prioritize a more performance-friendly fix.
 
Last edited:

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
I'll dig around the MOUNTAINS of plugins I'm using to see if there's anything like what you described @Shaz - thank you all so much for the help. I'll update the thread if I make any progress (or not).
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Something else might be the number of switches and variables you're using. Early in the game, you're generally accessing the lower numbered switches, but later in the game you're probably accessing the higher numbered ones.

I seem to remember reading a thread in Ace support that indicated if you use a LOT of switches, accessing the higher numbered ones takes longer.

I've never looked into the technical side of this to see how accurate it is, but it probably wouldn't be difficult to do some testing.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
I was honestly thinking it had to do with switches/variable usage, because my game is fairly large, and is using 250 variables and 720 switches.

I make sure to "purge" unused variables by resetting them back to 0 at regular intervals to make sure I don't have any of them getting crazy out of hand...but, yeah, that could very well be the culprit.

EDIT: Using the debug tool, using a new game, I turned on and off random switches (turn on about 70% of them) and then added numbers to almost all variables, ranging from -100 all the way to 500k+ and didn't notice any difference at all in the FPS - it remained at a solid 60 FPS. Having tested that and forcing the "playtime" counter to be set to 0 (and manually edited the core js file to stop updating it and the gameframe counter variable) - I am pretty much out of ideas.

My only guess now is that it is indeed a plugin I'm using. It's not a HUGE issue at the end of the day, but in wanting to optimize and make my game as "perfect" as I can, I suppose this will just be one of those issues I'll have to deal with.

Thanks for the help everybody.
 
Last edited:

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
what plugins? It's not a matter of the game being perfect or not perfect - if the game is lagging/stuttering, it's not going to be a great player experience. There are people here who are willing to help you. It'd be sad if you "give up" when there is help available.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
I have quite the list, but I'll go ahead and put up some screenshots :p
My guesses are that it is one of the following: Yanfly Save Core - SRD's KH Menu - CGMV Achievements. Each of those reference playtime in one way or another. I did turn them all off and then back on one by one to see if there was a point where it would change anything, but nothing changed, so I'm just throwing out guesses at this point.
pluginlist.png
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
Why are you fixated on it having something to do with referencing playtime? You have no evidence that that's got anything to do with it. I very highly doubt that it does.

It's very unlikely that any plugin that is for menus or new screens/scenes are going to affect what happens on the map. You're looking for plugins that do things on the map, if that's where the lag is happening.

You've got a number of Yanfly plugins that do things on maps, but if they caused issues, I'd expect them to happen right from the start of the game, and not get worse over time (and for other people to be reporting them as bugs). There are a number of MOG plugins that appear to be affecting graphics - weather, aura effects (only if it's on the map - if it's a battle plugin, it won't be the culprit), pixi filters. You've also got a couple of core engines that might be fighting with each other, but again, it's not something I'd expect would depend on how long you've been playing.

I would also look at anything that aliases the DataManager.makeSaveContents function, as well as anything that adds extra variables to any of the Game_... objects to see what it's doing with those new items.
 

bgillisp

Global Moderators
Global Mod
Joined
Jul 2, 2014
Messages
13,522
Reaction score
14,255
First Language
English
Primarily Uses
RMVXA
@Shaz : First post they say the FPS goes down as playtime goes up in the project. That's why they are looking at it. But I propose a test to try to isolate the cause:

Take one of the maps you noticed this on, copy it to an empty project. Do not worry about the events, plug-ins, or the database, just the map. Then run that project with just that one map for 48 hours or so, saving and exiting (reload the save when you come back) every so often. If the FPS does not drop then, then it is a plug-in somewhere that you added to the project. If it does drop, it is something in the core code that is causing it more than likely.
 

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
Why are you fixated on it having something to do with referencing playtime?
Mostly because I use a menu plugin that shows your playtime (and it's updating LIVE as you play). When referencing playtime in rpg_objects, you see this code:
Game_System.prototype.playtime = function() {
return Math.floor(Graphics.frameCount / 60);
};

Game_System.prototype.playtimeText = function() {
var hour = Math.floor(this.playtime() / 60 / 60);
var min = Math.floor(this.playtime() / 60) % 60;
var sec = this.playtime() % 60;
return hour.padZero(2) + ':' + min.padZero(2) + ':' + sec.padZero(2);
};
Breaking it down, the numbers here look something like this:
1 sec = 60 frames
10 sec = 600 frames
1 min = 3600 frames
1 hour = 216,000 frames
10 hours = 2,160,000 frames
20 hours = 21,600,000 frames
On a new save file, having only played for 1 hour means that the playtime being tracked in those variables is small, being only a number of 216,000, BUT, once you've hit 20 hours, that variable starts to look mighty huge.

Again, I could be very wrong in my assumptions here, and I probably am, but that's where my thought process is coming from in terms of thinking it was playtime. Now...to look at that mess, I turned off the menu plugin and the problem persisted, so that's where I figured that, yeah, it's not playtime, but something else altogether (as you said).

I too have looked at some of the on-map plugins I use and thought they would be the culprit, but upon turning a lot of them off and loading up the save file, the issue persists, so it is most likely as you said: There must be a plugin using a variable(s) somewhere that are just continuously increasing in size as the file is played more. I'll continue to dig around and see if I find anything suspicious.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
40,098
Reaction score
13,704
First Language
English
Primarily Uses
RMMV
First post they say the FPS goes down as playtime goes up in the project. That's why they are looking at it.
If that is correct, then you could start a brand new game, walk away and let it run (without the computer going to sleep) or just wander around the map, not interacting with anything, and not triggering anything, and after X number of hours the game would lag.

There must be a plugin using a variable(s) somewhere that are just continuously increasing in size as the file is played more.
I do not believe the "size" (value) of a variable would cause this. I could be wrong, but I'd look at a lot of other things first.
 

Aloe Guvner

Walrus
Veteran
Joined
Sep 28, 2017
Messages
1,628
Reaction score
1,115
First Language
English
Primarily Uses
RMMV
I seem to remember reading a thread in Ace support that indicated if you use a LOT of switches, accessing the higher numbered ones takes longer.
I think OP already tested this but this isn't the case in Javascript, accessing or setting array[99999] has the same time complexity as array[0]

@Fernyfer775 Can you run a performance profile from the Chrome DevTools for both the new game and the existing save? (if you're not sure how to do that, there's tutorials on YouTube for how to use Chrome DevTools)
 
Last edited:

Fernyfer775

Veteran
Veteran
Joined
Oct 6, 2013
Messages
1,317
Reaction score
818
First Language
English
I'll do as you both suggested and do the 24-48 hour playtime test on a fresh project with 1 map and see what happens. I'll post here when I have an update. Thank you so much for the help by the way, I really do appreciate it.

@Aloe Guvner - I do not know how to do that, but I will look into it and see! Thanks for the suggestion.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,864
Messages
1,017,056
Members
137,573
Latest member
nikisknight
Top