Pasted images into background slow down the app?
There is a fast loop that runs 10000 times and on each loop relocates an active object(star) at a random position and then pastes to the background. Why is it that after the loop is over the app is slower? Isn't the background just one big homogenous surface where things are drawn onto? Why does the number of pasted images matter?
Re: Pasted images into background slow down the app?
Have you tried both "paste image into background" and "add backdrop" to no avail? What are you pasting them as? Obstacles, no effect on collisions, etc.? Are you sure the stars themselves are being destroyed after they are pasted into the background?
Re: Pasted images into background slow down the app?
Hey Corlen
I haven't tried "add backdrop" because that is bound to be slower. They are pasted as "no effect on collisions". There is only one star that is randomly changing position per loop so destroying one active object wouldn't make a difference.
Re: Pasted images into background slow down the app?
Make sure you destroy them after "paste image into background".
Marv
Re: Pasted images into background slow down the app?
Again, that's not the issue because there is only one active object being relocated per loop. So there's only 1 star not 10000.
Re: Pasted images into background slow down the app?
This is not what you stated in your question.
How is there only one star? After you "paste image into background" did you destroy them? If not they are still in memory as 10,000 stars, fastloop or not. How is there only one star if you are pasting 10,000 of them? Please re-ask your question.
Marv
Re: Pasted images into background slow down the app?
If I understood correctly, he means he has a fastloop going up to 10,000 times that sets this one star's position to a random location and the pastes it into the background.
Are you only running the fastloop 10,000 times and then stopping it? Did you run the fastloop 10,000 all at once? If you did, this is going to potentially freeze your application because a fastloop is like the number you specified is a number of copies of the same code running at the same time.
Re: Pasted images into background slow down the app?
Yes you are right nivram, it is my fault, the question is misleading. I have edited the original post.
Re: Pasted images into background slow down the app?
Corlen the fastloop runs 10k times at the start of frame and there a freeze but that is not the problem. The problem is that the app runs 10 frames slower with the pasted stars than without. It is weird that it matters whether there's 10k,1k or 0 pasted stars. Isn't pasting to the background supposed to be blitting onto one single surface?
Re: Pasted images into background slow down the app?
No, that's not how it works at all.
When you paste objects into the background they are still saved as individual objects - regardless of whether you use "paste in to background" or "add backdrop".
That's why you can't keep creating them indefinitely (they count towards the object total), and why it's possible to delete them individually (using "delete created backdrop at").
The only difference between adding and pasting, is that pasted backdrops are deleted when the screen scrolls, whereas added backdrops are not.
What you really need to be doing, is pasting the stars into a surface/overlay object instead.
Re: Pasted images into background slow down the app?
That sucks. I was kind of hoping there would be a more light-weight way to do this than adding a surface object. Thanks everyone.
Re: Pasted images into background slow down the app?
Here's an idea:
How about you use a quick backdrop to tile an image of stars, and then paste a few extra individual stars (far less than 10,000) - just to make it look a bit random and break up the repeating pattern.
Re: Pasted images into background slow down the app?
That could work but another idea that came to mind is first pasting to a surface object, then pasting the surface object contents to the background as one big image, then destroying the surface object. It seems that might be the fastest way.
Re: Pasted images into background slow down the app?
Are there any plans in the future to make MMF3 not be bogged down by things off screen?
Re: Pasted images into background slow down the app?
I should note that there is also an issue with adding a backdrop Surface object if what you're doing happens to be creating a large tilemap using the paste background / add backdrop technique. You'll be tempted to add a Surface as a backdrop for speed purposes if you use a large Surface for your painting operation, since MMF handles large surfaces with a similar framerate drop. However, if you add a backdrop using a Surface object, while it will be faster for the CPU to process FPS-wise, it will add about ~4mb to the game's RAM usage depending (4mb was about the amount I got when adding a 1024x768 surface to the backdrop). This effect is cumulative due to something either with Surface or MMF's backdrop caching method itself.
Internally, MMF seems to cache the backdrop objects you create when you add them or paste them. For intrinsic objects like Active and Active Picture, it will release the memory on any frame jump. With Surface, it will only release the memory when the application is restarted. So, if you plan on creating a large number of backdrops in your game using Surface, you need to be aware of this....
My best advice to you until this behavior is fixed would be to try and figure out how to mitigate the number of backdrop objects you want to create. Don't create backdrops if the content of them is blank or can be expressed by larger objects (for example: if you always draw a house the same way, import the entire house as an object and use that instead). Once you get to about 3000-5000 backdrops, the game will start to slow down or become unstable. Try increasing the frame's object count to mitigate this (yes, I know, backdrops don't show up as objects in the debugger, but they're STILL enumerated as one for runtime purposes!)
Good luck to you. I've had to deal with these problems for a while now and I know what a pain in the butt they can be D:
Re: Pasted images into background slow down the app?
Noboyuki, thanks for you detailed response:)
My project doesn't really use backdrop objects much and mostly relies on active objects. However it's good to know how MMF2 deals with backdrop objects. What about destroying backdrop or active objects? Surely that frees memory, right?
Re: Pasted images into background slow down the app?
Yes, it should free the memory on frame jump. If I remember correctly, it still caches the backdrops in memory, even after they are "destroyed" in events, and "garbage collects" it on the frame jump. Usage is not cumulative as long as you change frames from time to time using intrinsic backdrops and actives.
Re: Pasted images into background slow down the app?
Are you running HWA mode? Because paste in backdrop DOES NOT work in HWA mode, instead it acts as add backdrop instead, so you have 10K backdrop objects slowing down the game.
Quote:
Originally Posted by MuddyMole
No, that's not how it works at all.
When you paste objects into the background they are still saved as individual objects - regardless of whether you use "paste in to background" or "add backdrop".
That's why you can't keep creating them indefinitely (they count towards the object total), and why it's possible to delete them individually (using "delete created backdrop at").
The only difference between adding and pasting, is that pasted backdrops are deleted when the screen scrolls, whereas added backdrops are not.
What you really need to be doing, is pasting the stars into a surface/overlay object instead.
Sorry mate but you are incorrect. Paste as backdrop does not add to the backdrop count, however there IS a limit to how many you can paste in one MMF loop.