Ren'Py Slow loading

Mr. MiBo

Formerly 'Bory_S'
Feb 25, 2023
3
0
I have a question about loading game saves. Here's how it goes. I started creating a game in Renpy, at first everything was fine, but the longer the game became, the longer it took to load the saves ( about 10 seconds ). The code is not complex, I would even say it is very simple, and that is why it annoys me so much. I've probably tried everything, today I even reinstalled the system and it's still the same.
Any ideas how to solve this?
 

Nicke

Well-Known Member
Game Developer
Jul 2, 2017
1,197
3,082
Before anne o'nymous comes in and solves it for you, I'll take a stab in the dark. Call stacks? (You use calls but don't return from them.)
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
999
2,097
I have a question about loading game saves. Here's how it goes. I started creating a game in Renpy, at first everything was fine, but the longer the game became, the longer it took to load the saves ( about 10 seconds ). The code is not complex, I would even say it is very simple, and that is why it annoys me so much. I've probably tried everything, today I even reinstalled the system and it's still the same.
Any ideas how to solve this?
Are you trying the game outside of the SDK environment? It's possible you have done lots of changes and what not and the Ren'py SDK is caching variables and call stacks etc. When I am working on code, I sort of have a habit of recompiling the rpcy files and also deleting any persistent variables after I do some major changes to the code.

I've never seen a long save load before though. I see lots of games that go over-board on the coding and they end up taking 2 minutes or more to load in when you first run them.

My feeling is it must be some sort of accumulative effect from coding and making changes. To troubleshoot, I would run a build off and then try and play it normally, without the SDK running. See if that makes it any faster.

I'm curious to find out what it is.
 

poolfk

New Member
Jul 18, 2024
3
2
I have a question about loading game saves. Here's how it goes. I started creating a game in Renpy, at first everything was fine, but the longer the game became, the longer it took to load the saves ( about 10 seconds ). The code is not complex, I would even say it is very simple, and that is why it annoys me so much. I've probably tried everything, today I even reinstalled the system and it's still the same.
Any ideas how to solve this?
You can check whether the stack is affected by writing the following to the console after loading - `watch len(renpy.get_return_stack())`.
But I believe that your problem is related to something else.

Have you defined the `after_load` label? Maybe you added some callbacks?
You may be using a lot of `show` without `hide`, but to get a side effect of 10 seconds...
For that you need really many images and I guess with some kind of `atl`. I think that's unlikely.
 
Last edited:
  • Like
Reactions: osanaiko

79flavors

Well-Known Member
Respected User
Jun 14, 2018
1,583
2,222
I'll take my random guess.

You're using show for background images instead of scene.

show adds an image to an existing screen.
scene replaces the screen with an image.

The difference being that when you've shown 1,000 images using scene, only the final one is actually being shown (and therefore tracked). Whereas 1,000x show means RenPy would be tracking 1,000 active/current images.

For a better answer, build your game using the RenPy SDK BUILD and upload it somewhere. Doesn't matter if it's not finished or not working. Then upload a save file from the /save/ folder to the same place. Then post the links here. If you'd rather not post it publicly, send a PM to the people in this thread you trust to know enough to diagnose it. F95 is a pirate site, but we're more of less trustworthy (at least for a completely unfinished game).

That way, we can look for ourselves. No offence, but "my saves don't work" isn't really much to go on. The details matter, and seeing the game AND the saves are likely needed to solve this one (assuming it isn't a problem with your computer).
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,300
3,964
79flavors I agree that the above "too many 'show's" theory is one plausible explanation.

However, I'd like to add some nuance, in case anyone is learning from this thread:

The show command adds an image to an existing screen. However, when the image name is made up of parts, such as "sylvie blue normal" and "sylvie blue smile", then renpy is smart enough to use the first part(s) of the image name as "tags", and will replace the previous image that has the same tags as the new image.

This is one of the many helpful-to-VN-creators functionalities that RenpyTom has built into the engine. It basically allows you to not have to worry about "hiding" the previously shown character sprite when showing a new variation during a dialog. Of course, at the end when the character goes off-screen, you need to hide the tag manually.

So, depending on how the game is implemented, if you are using sprites and following the image file naming pattern described in the docs/example game, you can certainly end up with far less images loaded into the buffer than the number arrived at by simply counting the "show" commands.
 
  • Like
Reactions: anne O'nymous

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,375
15,288
[...] but the longer the game became, the longer it took to load the saves ( about 10 seconds ).
Okay, this is absolutely not normal. Even with a slow hard disk, a save file shouldn't need more that 5 seconds to be loaded ; yet only when it's really big.

The previous answers are valid, but first thing first, what are the size of the save files, and how does it vary with time ?

On average, a save file for a Ren'Py game is around 300 KB at most, and after one or two saves (at max) the size should be relatively constant. By "relatively constant" I mean that it can grow, but that growth should be around 10 KB for each saves.

If your save files are in that range, then it's probably 79flavors who's right. The save file load quickly, but then Ren'Py need a lot of time to process all the images it have to display on top of each others.

If the save files are already above 300 KB after one or two saves, then there's too many variables inside. And I mean "inside the save file", not "inside the game".
Not everything need to be saved, it's why there's a define statement (that variable don't need to be saved), and a default one (that variable need to be saved). More on the subject in that thread.

If the save files size grow significantly between two saves, the cause is probably that your variables have way too long names.


As reference, a game with around 1,500 variables, that have really long names (half are over 200 characters), only need ~300 KB of space, and load in less than 2 seconds.
The same game with my Variable Viewer, that double each variables and their name, only need ~500 KB of space, and load in around 5 seconds.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,375
15,288
[Sorry for the double post]

A word on this one:

Before anne o'nymous comes in and solves it for you, I'll take a stab in the dark. Call stacks? (You use calls but don't return from them.)
While they add in complexity, unreturned calls shouldn't have a significant impact on the loading time.
It will increase the size of the save file, sometimes more than significantly, but Ren'Py will not care about the stack size once the data are loaded, just branching where the save was made, exactly like it will do if the call stack was empty.
 

osanaiko

Engaged Member
Modder
Jul 4, 2017
2,300
3,964
I love that there's multiple people in here trying to help while the OP, who has only ever made this single post on F95, has not returned.
 
  • Haha
Reactions: Turning Tricks

Mr. MiBo

Formerly 'Bory_S'
Feb 25, 2023
3
0
Relax. I wrote this post late in the evening. I sleep at night and work in the morning, so please understand. Ok, back to the topic of the post, actually using show instead of scene caused me a headache. After this change everything is fine. I know I probably look like an idiot, but I still thank you all for your help. Oh, I forgot, if I have any other pressing problems, I will contact you guys ;) Once again, many thanks :)
 

Turning Tricks

Rendering Fantasies
Game Developer
Apr 9, 2022
999
2,097
Relax. I wrote this post late in the evening. I sleep at night and work in the morning, so please understand. Ok, back to the topic of the post, actually using show instead of scene caused me a headache. After this change everything is fine. I know I probably look like an idiot, but I still thank you all for your help. Oh, I forgot, if I have any other pressing problems, I will contact you guys ;) Once again, many thanks :)
No worries

FWIW, the has gotten a LOT better over the last year or so... now with lots of examples. And the tutorial projects that ship with Ren'py are also very helpful about the basics. For example, there's a Quickstart section on the Docs that goes through all the basic functions you need to start a basic VN. It even specifically explains the difference between show and scene ;)

And there's tons of Youtube tutorials out there... just be aware of the dates on some of them as Renpy has been around for a while and anything more than 2 or 3 years old is probably outdated.

A couple of my favorite resources for learning are (formerly Thundorn Games) for his easy to follow and understand YouTube videos. Another Youttube one I like is , although her content is a little more basic. And a good reference site I like is page. they do an awesome job explaining stuff like variables and positioning in Ren'py.
 

Mr. MiBo

Formerly 'Bory_S'
Feb 25, 2023
3
0
Thanks buddy, it will definitely come in handy. Apart from that, I am impressed and pleasantly surprised by this forum. Despite my slightly stupid question, I got answers that helped me. I used other websites with different topics and when someone asked a question, they usually got an answer in the form of: search on Google