Loading Times and RAM Usage

YodapolloYodapollo Inactive, Chef Emeritus Posts: 447
edited November -1 in News from the Dev Team
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
«134

Comments

  • beefy_clyrobeefy_clyro Member Posts: 5,394
    Thanks for the post yoda, its great to see you have addressed the communities concerns and are looking at reducing load times as a priority. Excited to see 0.9.8
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Im glad you are working one this.

    I Would like to se Example codes of this best practices.

    Cheers.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Thanks; excellent stuff; excited to see 0.9.8 like beefy (+like everyone...) and ditto to what Magonicolas said! :-)

    ----------------------------------------------
    http://www.davidgriffinapps.co.uk/

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • osucowboy18osucowboy18 Member Posts: 1,307
    Thanks for the update Yoda! Looking forward to 0.9.8!

    - Alex
  • InLikeFlynnInLikeFlynn Member Posts: 171
    Thanks for this info Yodapollo. Would calling images as needed instead of preloading affect performance as spawning does?
  • gariantrollgariantroll Member Posts: 219
    I always did this Yoda, but I don't understand why the Memory still goes up between scenes and never goes down properly. For example my Menu Screne is initially 23.8 MB, then I go to the first stage and it usually never goes over 120MB, but if I go back to the Menu Screenit is now 68MB. THis happens on all stages and eventually shuts down because of this. THe memory never seems to dump for the next stage. Any suggestions?
  • gariantrollgariantroll Member Posts: 219
    Also, I you shouldn't have to put .png at the end of the image. I think after a particular version we are not permitted to have .png at the end of the file.
  • PhoticsPhotics Member Posts: 4,172
    Yodapollo said:
    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.

    This doesn't make sense... does GameSalad have arrays? I wasn't aware that comma-separated lists worked in GameSalad. I thought that a text attribute was just for text.
  • gamedivisiongamedivision Member Posts: 807
    thank you GS its very much appreciated
  • sebmacflysebmacfly Member Posts: 1,018
    Thanks for da info YODA!
  • EastboundEastbound Member, BASIC Posts: 1,074
    Photics said:
    This doesn't make sense... does GameSalad have arrays? I wasn't aware that comma-separated lists worked in GameSalad. I thought that a text attribute was just for text.

    Agreed, I don't see how we would access the information in this string or manipulate it.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    I really need an example :P

    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.
  • osucowboy18osucowboy18 Member Posts: 1,307
    Photics said:
    This doesn't make sense... does GameSalad have arrays? I wasn't aware that comma-separated lists worked in GameSalad. I thought that a text attribute was just for text.

    My guess is in the condition of a rule, check to see if the string attribute "contains" a certain line of text. Hope that helps :)

    - Alex
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Thanks Yoda. However I must agree that the last part of your post is a little hard to understand (maybe it's because it's past midnight here).

    Would it be possible for you to elaborate it a little more, maybe with some more examples?
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Last year someone put together a wake to fake arrays. I can't find it though
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Also if we can use the text attribute like this, how many characters would it be the maximum (in terms of performance) that it could handle?

    Because if this really works I may have found a big workaround on a problem I've been smashing my head for months.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Hello All.

    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".
  • GamersRejoiceGamersRejoice Member Posts: 817
    Interesting. I'm glad to hear that this is being addressed.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    @MarkOnTheIron The longest text attribute I have has 647 characters and it works fine. It could probably take more characters. And I have a few of those types of attributes. They help me define enemy abilities and types.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Please CodeMonkey make us a template for a better understanding of this.
  • gamedivisiongamedivision Member Posts: 807
    i would surly appreciate some form of template for this codemonkey and thank you for taking the time to explain
    CodeMonkey said:
    Hello All.

    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".

  • PhoticsPhotics Member Posts: 4,172
    CodeMonkey said:
    Let me address how some of the suggestions work.

    Oh, ha ha... that's clever. So, it's like a one-way database. This would be good for games like poker, knowing which cards were used.

    I don't see how reducing attributes improves performance. Aren't they're supposed to be tiny?
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Sorry, the template will have to wait till next week so it can look good and be understandable.

    @Photics, its also about reuse. Less attributes can mean using less rules to check values of those attributes.
  • GruntGrunt Member Posts: 109
    Eastbound said:
    Agreed, I don't see how we would access the information in this string or manipulate it.

    You can probably check the tutorial on using images as numbers for changing score fonts by tshirtbooth if I got this right
  • creativeappscreativeapps Member Posts: 1,770
    Thank you so much Yoda & CodeMonkey. For giving tips on Ram Usage & Loading time. We are appriciated. And waiting for the next update which makes gamesalad more powerful.
  • HoneyTribeStudiosHoneyTribeStudios Member Posts: 1,792
    Interesting text attribute tip, cheers. Be great if we could also remove entries from it!

    Look forward to more tips or perhaps a full optimisation guide.

    Shaz

    --------------
    image
    "...the resulting sonic effect is almost mesmerising." Pocket Gamer
    Sound design and music service available: http://tiny.cc/MusicService
    www.HoneyTribeStudios.com
  • PhoticsPhotics Member Posts: 4,172
    CodeMonkey said:
    Photics, its also about reuse. Less attributes can mean using less rules to check values of those attributes.

    ...but is that the Rules slowing things down or the attributes?

    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.
  • Rob2Rob2 Member Posts: 2,402
    It all seems a bit smoke and mirrors to me. I thought people were experiencing a massive drop in performance with 971.
  • chaleychaley Member, PRO Posts: 226
    Sounds encouraging... Thanks!
  • ORBZORBZ Member Posts: 1,304
    The #1 way to improve performance is uncheck the Movable flag on actors that are not under the control of the physics engine.

    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.
Sign In or Register to comment.