closing the menu freezes with big parallax

so I have a max size world map, I don't want to use tiles but instead I'm painting manually a huge background image I'm adding with parallax, in game it works just fine. but when I open the menu and then close it it freezes for a second or two. I've tried saving the parallax to a cache so it doesn't have to load the data again, but I've found that the freeze happens after the parallax is assigned, so it seems like the problem is not what I thought.
something is taking a long time to process but I don't know what, and it only happens when I have the big parallax in the room. Anybody knows something about this?
1737239279173.png

it's a 256*256 map at 10% zoom (WIP)
It simply means that your computer has not enough RAM to handle that.

When the menu opens the engine takes a screenshot to use as a menu background. When the menu is closed, that screenshot can be removed from memory - but that takes a bit of time.

And what you describe seem to indicate to me that the picture cache is almost full, so that the added background screenshot pushes it over the limits, causing lag due to missing RAM.

Which is also no wonder due to that extremely large parallax.

A few years ago I still told people that you'll need a top-of-the-line computer to handle 150x150 tile parallax maps without problem. Today's computers are better, but you still need one hell of a RAM to handle that large of a parallax.

Just think of it - a tiled map needs one number per tile, multiplied by the number of map layers.
A picture needs 3 color numbers (RGB ) for each pixel, with 48x48 pixels per tile. And multiply that if you use additional layers for above player or light or similar.

So it is no joke to say that a parallax map needs around two thousand times the RAM of a tilebased map.
And a picture cannot be compressed while being used, so the compressed file size does not count. Save your background as BMP to see its real size - BMP has no compression.
It simply means that your computer has not enough RAM to handle that.

When the menu opens the engine takes a screenshot to use as a menu background. When the menu is closed, that screenshot can be removed from memory - but that takes a bit of time.

And what you describe seem to indicate to me that the picture cache is almost full, so that the added background screenshot pushes it over the limits, causing lag due to missing RAM.

Which is also no wonder due to that extremely large parallax.

A few years ago I still told people that you'll need a top-of-the-line computer to handle 150x150 tile parallax maps without problem. Today's computers are better, but you still need one hell of a RAM to handle that large of a parallax.

Just think of it - a tiled map needs one number per tile, multiplied by the number of map layers.
A picture needs 3 color numbers (RGB ) for each pixel, with 48x48 pixels per tile. And multiply that if you use additional layers for above player or light or similar.

So it is no joke to say that a parallax map needs around two thousand times the RAM of a tilebased map.
And a picture cannot be compressed while being used, so the compressed file size does not count. Save your background as BMP to see its real size - BMP has no compression.

I did some debugging and it doesn't appear that lack of memory is the problem, because I added some logs to see if the freeze happens before or after the cache and the freeze happened after the parallax was handled. I managed to track down the freeze to the line 1988 of SceneManager.updateMain, now when it comes to handling the parallax in game it works perfectly smoothly and I also tried it by uploading it to itch.io and it worked fine. it's just at this moment of closing the menu that I get the freeze.
1737242289023.png


I managed to further track the freeze down to this part, it's in the SceneManager.renderScene and the method called on line 2035 is outside code, so it seems like the freeze has to do with the rendering, apparently when you open the menu the world is erased and when you close it then it has to be drawn again, and for some reason the first render takes much longer. if only I could stop the map to stop being rendered when opening the menu.

1737242967421.png
I assumed that I was using events that were not plugins, however, here are some comments about map transitions and event movements on large maps.

The maximum menu size that I achieved was using 4 screens, a map defined by a specific size, and as the screen resolution allowed, I could create up to 4 of these maps in different positions, straight lines, in an "L" shape or squares.

This specific limit value was precisely because of the limitations, both of event lag and frame drops.

Therefore, the larger the map, the more detrimental it is to controlling events on it. I think that the limit of map events is only 1000, while a 256x256 map far exceeds this amount of tiles.

Even the amount of variables associated with the event would be exceeded, since there are directions, map positions and screen positions and their storage, which would take something around 10 variables per event.
I assumed that I was using events that were not plugins, however, here are some comments about map transitions and event movements on large maps.
I am testing this in an empty map with no events and no plugins and I still get the freeze, BUT if I never open the menu it works great. I can even have the player move to a different map and came back and it loads quickly.
edit: I did some more testing and if the player moves to another room and comes back to the world map it takes the same amount of time as when closing the menu.
I know, so a 256x256 map is a lot to map, it's the maximum limit for maps, isn't it?

You can use the parallax marked on the map in its properties, and reduce the number of events on it.
maybe I could create my own custom menu so that it doesn't make a whole new scene every time the player opens the menu...
Maybe you can try this?
or try [MAC_High)Hz_Fixes] that only update when it's required.
I have this also inside my base for the sceneManager I didn't have.

so it might help as the parallax shouldn't update anyway.
maybe I could create my own custom menu so that it doesn't make a whole new scene every time the player opens the menu...

I've heard of people who had to rework all their larger maps, as they hit the limits of the engine with oversized parallax images.
You might shut down one symptom with a custom menu, but there will be more problems. Like every map change should have the same effect as the scene change from open/close the menu. I've been there when I stresstested the memory leak of HUD Maker Ultra.

If you encounter issues like this already when your map is empty, you might want to reconsider the concept, as it'll only get worse. And the more effort is in there, the harder it'll get to redo everything. Just as a sidenote.
Maybe you can try this?
IT WORKED!
1737246766505.png
plz marry me!
jk, jk, thank you so much.
I've heard of people who had to rework all their larger maps, as they hit the limits of the engine with oversized parallax images.
You might shut down one symptom with a custom menu, but there will be more problems. Like every map change should have the same effect as the scene change from open/close the menu. I've been there when I stresstested the memory leak of HUD Maker Ultra.

If you encounter issues like this already when your map is empty, you might want to reconcider the concept, as it'll only get worse. And the more effort is in there, the harder it'll get to redo everything. Just as a sidenote.
I've been worrying about that but it seems that what's causing the lag is just loading the image, which since its a png it's already as big as it's gonna get, so if something is going to give me trouble then it has to be something else.
are you thinking about something in particular? too many events? I've been thinking that putting too many of those could seriously lag the thing, specially since I want to put a bunch of conditions to a lot of them. I really don't want to lose the big world map because basically it's the whole point of the game, there won't be much else but the world map.
I basically drew the general layout and I'm slowly filling it out:
1737247721070.png
Maybe you can plit the image if it is bigger than 1000 or 2000 pixels. Not sure if every computer can load large textures without performance drops.
are you thinking about something in particular? too many events? I've been thinking that putting too many of those could seriously lag the thing, specially since I want to put a bunch of conditions to a lot of them.
Depends on what these events are doing. I've read warnings about having too many events, but never seen a critical number. Parallel processes do have the biggest performance impact.

The only severe performance issues I had so far in my project were caused by HUD Maker Ultra, which was basically spamming a lot of HUD clones into my RAM without being able to remove unused instances. Eventually, it got laggy and even crashed if I pushed it too far.
So - if your game is facing trouble already, anything that'll cause additional work might be the final straw. Like a not performant plugin. Or maybe you pile up some other usual garbage in your cache while playing and loading this map after 4 hours of gameplay isn't as smooth as it is at session start. And what about players with weaker systems?

That's what I'm always worried about. Don't have a solution tho, except split the map into smaller pieces, but I can imagine you like the feeling of wandering through the whole thing without some "gatekeep passages".
Maybe you can plit the image if it is bigger than 1000 or 2000 pixels. Not sure if every computer can load large textures without performance drops.
probably not, but my computer is pretty old and it can handle it so I'm guessing it's ok. I also put the thing on itch and run it through my phone and it worked. so I'm guessing it's safe, in so far as having a big bitmap image.
by the way the size is 12288², its 256*48. and I'm also using a bitmap for the collisions with Qmovement, but that plugin can resize the image to a lower resolution for the collisions.

Original thread: https://forums.rpgmakerweb.com/threads/closing-the-menu-freezes-with-big-parallax.174813/