Loading Times and RAM Usage
Yodapollo
Inactive, Chef Emeritus Posts: 447
Hey guys,
We have been investigating the loading times and RAM usage issues and wanted to address those with you.
Looking at games within the community, we can see that the size of the game does not always effect the load times and RAM usage. This shows us that this issue is not just an issue with the Creator tool, but also a result of how each user is developing and optimizing their game.
Internally, we are implementing new benchmarking procedures to continue to closely monitor the flux of RAM usage. We are also in the final stages of rolling out a new loading system for iOS devices, which will reduce load times roughly by half for our largest games. We are also developing an improved saving and publishing process.
All of those changes are slated for completion and delivery with GameSalad 0.9.80. We understand that better performance on iOS devices is an absolute must and it is our top priority in regard to our engine. These are changes that are and have been worked on for quite some time and we’re very excited to roll them out in the next major update.
In the meantime, our in-house Creator guru, CodeMonkey, has put together some best practices that can help you see marked improvements in the performance and load times of your games:
No Image Preloading and Moreover Less Behaviors
Instead of the ‘Change Image’ behavior, try using ‘Change Attribute’ on the self.Image attribute instead and set the value as you need the image.
This will require that the images be named "enemy1.png", "enemy2.png", "enemy3.png", and so on, but a small price to pay for noticeable improvements with image loading. Now, you can just change the image to "enemy"..game.Enemy1..".png" and you only need one behavior instead of a ‘Change Image’ behavior and corresponding Rule to check which enemy is selected for each of those ‘Change Image’ behaviors. Not only does that shrink the amount of behaviors needed, the images are not preloaded either, thus reducing initial load times.
You can also use this method in place of the ‘Animate’ behavior. Instead, use the method above in a timer and name the sequence of images appropriately to accommodate the frame counter.
Example: I have an attribute for FramesPerSecond, an attribute for max number of frames in the sequence, and an attribute used as a counter for the frame number.
Using a Timer to run every 1/FramesPerSecond, I increment the counter attribute and change the image using Change Attribute to "Hero"..game.HeroType.."_"..game.AnimationType.."_"..game.frameNumber..".png"
This same method is used in The Secret of Grisly Manor, but on a much larger scale.
Other benefits of using this method are being able to use the Image name as a point to trigger a sound or some other action.
However, keep in mind this method is not optimal for HTML5 because it isn't preloading the images. Each platform is different, and some methods work better on ones than on others. Right now, we’re focusing on improving performance on iOS devices.
Fewer Attributes
Try using text/integer attributes as lists/containers to group similar attributes. This cuts down on the number of attributes you need. So instead of 117 attributes to keep track of their found state, there is one text attribute that contains a comma-separated list of enemies found by their type/id combination.
Also, use the Rule Condition on an attribute with expression editor to find a specific value. Use integers as a binary on/off switch for multiple settings (e.g., The hero status effects would be a value like, 1101, where the thousands digit represents stun state, hundreds digit is the poison state, etc.).
We certainly hope these best practices prove useful for everyone here, and we’ll try and get some more out in the near future. We’re also aiming to get 0.9.80 ready for release as soon as we can. Thank you, everyone, for your feedback and comments. Your input continues to inspire us to make GameSalad everything we all want it to be.
Thanks.
--Yodapollo
We have been investigating the loading times and RAM usage issues and wanted to address those with you.
Looking at games within the community, we can see that the size of the game does not always effect the load times and RAM usage. This shows us that this issue is not just an issue with the Creator tool, but also a result of how each user is developing and optimizing their game.
Internally, we are implementing new benchmarking procedures to continue to closely monitor the flux of RAM usage. We are also in the final stages of rolling out a new loading system for iOS devices, which will reduce load times roughly by half for our largest games. We are also developing an improved saving and publishing process.
All of those changes are slated for completion and delivery with GameSalad 0.9.80. We understand that better performance on iOS devices is an absolute must and it is our top priority in regard to our engine. These are changes that are and have been worked on for quite some time and we’re very excited to roll them out in the next major update.
In the meantime, our in-house Creator guru, CodeMonkey, has put together some best practices that can help you see marked improvements in the performance and load times of your games:
No Image Preloading and Moreover Less Behaviors
Instead of the ‘Change Image’ behavior, try using ‘Change Attribute’ on the self.Image attribute instead and set the value as you need the image.
This will require that the images be named "enemy1.png", "enemy2.png", "enemy3.png", and so on, but a small price to pay for noticeable improvements with image loading. Now, you can just change the image to "enemy"..game.Enemy1..".png" and you only need one behavior instead of a ‘Change Image’ behavior and corresponding Rule to check which enemy is selected for each of those ‘Change Image’ behaviors. Not only does that shrink the amount of behaviors needed, the images are not preloaded either, thus reducing initial load times.
You can also use this method in place of the ‘Animate’ behavior. Instead, use the method above in a timer and name the sequence of images appropriately to accommodate the frame counter.
Example: I have an attribute for FramesPerSecond, an attribute for max number of frames in the sequence, and an attribute used as a counter for the frame number.
Using a Timer to run every 1/FramesPerSecond, I increment the counter attribute and change the image using Change Attribute to "Hero"..game.HeroType.."_"..game.AnimationType.."_"..game.frameNumber..".png"
This same method is used in The Secret of Grisly Manor, but on a much larger scale.
Other benefits of using this method are being able to use the Image name as a point to trigger a sound or some other action.
However, keep in mind this method is not optimal for HTML5 because it isn't preloading the images. Each platform is different, and some methods work better on ones than on others. Right now, we’re focusing on improving performance on iOS devices.
Fewer Attributes
Try using text/integer attributes as lists/containers to group similar attributes. This cuts down on the number of attributes you need. So instead of 117 attributes to keep track of their found state, there is one text attribute that contains a comma-separated list of enemies found by their type/id combination.
Also, use the Rule Condition on an attribute with expression editor to find a specific value. Use integers as a binary on/off switch for multiple settings (e.g., The hero status effects would be a value like, 1101, where the thousands digit represents stun state, hundreds digit is the poison state, etc.).
We certainly hope these best practices prove useful for everyone here, and we’ll try and get some more out in the near future. We’re also aiming to get 0.9.80 ready for release as soon as we can. Thank you, everyone, for your feedback and comments. Your input continues to inspire us to make GameSalad everything we all want it to be.
Thanks.
--Yodapollo
Comments
I Would like to se Example codes of this best practices.
Cheers.
----------------------------------------------
http://www.davidgriffinapps.co.uk/
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
- Alex
Also, if you guys say this is the correct way of doing it instead of Change image and animate, Would be much more easy if you fix change image and animate to make it work like this.
Cheers.
- Alex
Would it be possible for you to elaborate it a little more, maybe with some more examples?
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Because if this really works I may have found a big workaround on a problem I've been smashing my head for months.
Let me address how some of the suggestions work.
If you have a text attribute, you can easily append to it using the Change Attribute behavior. For example, if you have the game attribute game.UsedCards and store which cards have been selected, you can append to the text attribute, the card that was selected. Separating it by commas will make it easier to find a specific card.
Initial value for game.UsedCards is ,2Hearts,4Clubs,KingSpades,
If you draw the Queen of Diamonds, you change to game.UsedCards to game.UsedCards.."QueenDiamonds," so the new value is now ,2Hearts,4Clubs,KingSpades,QueenDiamonds,
Now using the Rule condition if Attribute game.UsedCards contains ",QueenDiamonds," then run some behaviors. You can also use the expression editor for the right hand side of that condition to use attributes for the search term.
Although you won't be able to easily remove values from the text attribute, you won't need 52 attributes/rules to check if a card has been selected.
Now if you used an integer attribute and just used each digit as an on/off switch, you get a specific digit using the mod % function.
game.Lightswitch%10
@gariantroll you can use the ".png" the change the value of the self.Image attribute, but after a certain update, rules that are checking if the self.Image is "yourImageName.png" might work better if you check if the self.Image contains "yourImageName".
I don't see how reducing attributes improves performance. Aren't they're supposed to be tiny?
@Photics, its also about reuse. Less attributes can mean using less rules to check values of those attributes.
Look forward to more tips or perhaps a full optimisation guide.
Shaz
--------------
"...the resulting sonic effect is almost mesmerising." Pocket Gamer
Sound design and music service available: http://tiny.cc/MusicService
www.HoneyTribeStudios.com
If I had a thousand attributes, and only used three of them per scene, would that slow things down?
If the advice is to cut down rule usage, that makes sense to me. If the advice is to cut down attribute usage, that's a problem. I don't see why storing some data would result in the massive Loading times and RAM usage problems that we're seeing.
If you move an actor by hand (plot it's xy manually) then uncheck movable. If the actor is supposed to collide and bounce in a realistic way then check movable.
Also, I'm amused that a "codeless" system like this makes the "novice" user use binary logic to store lists of things in an int. How about you just provide some bitwise operators if you really expect us to manipulate ints like that? << >> & | and ^ plz. You could make them functions(). lshift, rshift, bitand, bitor, bitxor.
Or better yet. List data type.