GS Mythbusters? White Square Image loading optimisation

StuartYStuartY Member Posts: 134
edited November -1 in Working with GS (Mac)
One of the things that's irked me - and everyone else, apparently - about working with GS are the long loading times. I've heard of various techniques to try and keep it down. These vary from the proven, common sense (using smaller images, being aware of the 2* rule, loading similar levels sequentially) to stuff which is less proven and may or may not have something in it - the alternative medicine of the GS world, so to speak.

One of the most prevalent appears to be working using "white square" actors and adding a rule to change their image as soon as the level starts to the correct image. Apparently, this is meant to reduce the time GS spends pre-loading image files. The only complication; you have to work in a blizzard of white squares when you're actually positioning stuff in your game.

Well, I didn't fancy the thought of having to blunder around in the dark (or the light, in this case) trying to assemble every level in my game. So I decided to do a test and see if this technique actually works.

My conclusion: It doesn't.

I opened up a simple project I've just finished. I had assembled a level using the white squares technique. Then I placed the "real" images on to all the blank actors. I opened it in the iPhone viewer - once before, once after. I timed the loading of the scene in question with a stopwatch. The results:

With white squares: 10.6 seconds
Actors with images: 10.3 seconds

This doesn't prove the inverse - that not using white squares is actually faster - human error could account for the 0.3s. But it does seem to suggest that the white square technique has little, if any bearing on load times.

My project has far more audio than images, so I stripped the audio out and repeated the test to be sure:

WS: 2.0s
Images: 1.8s

Again, marginally quicker without the WS.

Maybe this used to work and it doesn't in 0.93. I don't know. But considering as I was unable to discover any advantage at all to using this technique, I'll be forgetting about it and working with GS normally from now on.

What are your opinions on the matter? I'd be particularly interested to here what the devs or sous-chefs think. Has anyone else who uses it tried similar tests?
«1

Comments

  • PhoticsPhotics Member Posts: 4,172
    While working on BOT, I tested it. At first I thought it didn't work, but then I put the "Change Attribute" behavior in a 0.01 second timer. I noticed a significant reduction in loading times.
  • StuartYStuartY Member Posts: 134
    With Photics' suggestion, I ran the test again. The results:

    WS: 1.8s
    Normal: 2s

    Again, about the same, but I think the WS had a slight edge. It's also worth noting that Photics' method produced a few 1/10s of white squares in the level before the images had loaded.

    I'm going to make a test project with an absurd quantity of images so I can test this over a much longer timescale, eliminating the possibility of human error.
  • PhoticsPhotics Member Posts: 4,172
    I'll rerun the test. I hate having to work this way, but I did notice a significant difference.
  • GamersRejoiceGamersRejoice Member Posts: 817
    I'm very interested in this because I too have not been able to produce better results than just the standard way.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    Hope someone figure out good techniques for loading times!

    I also did white squares test (With no timer) and it didn't work.

    Cheers.
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    be great if this works well..

    do you notice the squares before your images load? ...

    are you testing through the GS viewer or Adhoc builds...?
  • StuartYStuartY Member Posts: 134
    I'm using GS viewer at the moment, but I'm going to make a couple of Adhocs for the "big" test that I'm working on right this minute.

    Photics, I'd also be interested to know how you "stripped" the default images from your project - how does one set about "going back to white"?
  • LumpAppsLumpApps Member Posts: 2,881
    About having to build your game in white squares.

    What if you build the game with an image in the actor and then before publishing throw them out. The actors will turn white again but no problem there because the .self trick is in it. My suggestion is to use a different name than the one in the .self trick ore you will get blanks there when the images are thrown out.
    For example make a copy of each image and call them image.png and XXXimageXXX.png
    The XXXimageXXX.png will be the one you throw out.

    I just did a test and this works fine ;)
  • PhoticsPhotics Member Posts: 4,172
    StuartY said:
    Photics, I'd also be interested to know how you "stripped" the default images from your project - how does one set about "going back to white"?

    I have a Prototype actor called "Blank" that I use to create instance actors on the scene. I then can drag the image into those actors. When I'm done, I just click the image data and click the "Revert to Prototype" button.

    Second-half of the test is commencing... the "fast" number is 3.3 seconds.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Maybe it would help if you started out by spawning 5,000 white squares, then destroy them, then every .1 seconds, spawn and destroy all of your actors. It might help with performance.

    Seriously, though, I'm looking forward to seeing how this all plays out in the end.
  • PhoticsPhotics Member Posts: 4,172
    Test complete...

    Traditional - 4.3 Seconds
    White Box / 0.01 timer - 3.3 Seconds
  • LumpAppsLumpApps Member Posts: 2,881
    Great to hear tshirt. I am not yet building big games but this helps a lot.

    What do you guys think about my trick mentioned above. I can post my test if you guys like but it is perhaps clear the way its told (dunno if my Dunglish is well enough ;)
  • codematescodemates Member Posts: 112
    I rebuilt my whole game with white boxes and went from 16secs to 4 sec load. It works.
  • StuartYStuartY Member Posts: 134
    Here are the results of my purpose built test (48mb worth of 1024*768 wallpaper images) using the GS viewer. Adhocs not done yet. Hardware = iPhone 4.

    Normal (images already selected): 5.8s
    No Timer, Change Attribute technique: 6.0s
    Timers set at 0.001s: <1s loading time, but white squares until 5.5s

    So - the timer method has it overall, and wins in initial loading times as well. But, it might result in blank images for a noticeable period of time if your project is image heavy. Loading FROM a white screen might help to conceal this. The one thing you definitely shouldn't bother with is changing the images without a timer.

    Next, I'll try it with adhoc builds and see if that makes any difference.
  • LumpAppsLumpApps Member Posts: 2,881
    Perhaps it helps if you also use the interpolate trick for timers?
  • StuartYStuartY Member Posts: 134
    After making AdHoc builds, the results remain similar;

    Normal: 7s
    Change Attribute: 6.7s
    Change Attribute with timer: <1s - but takes 6.2s to fill in white squares.

    I also tested level switching in the viewer, going between two identical levels. For this, I used the timer method and the normal method. Both resulted in sub 1s load times when the second level was loaded. With the timer method, however, it appeared to have "forgotten" the images and still took 5.5seconds to change from white squares.

    So - at the moment it would seem like a pretty good trick for things like the menu screen TSB was talking about, but seems to generate some disadvantages when it comes to changing between similar levels.

    Ludwig - next on my list is to use interp. as a timer, see if that changes the situation. Also, your trick with deleting duplicate images seems to be a pretty clever way of side-stepping the biggest drawback.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    tshirtbooth said:

    Also ill not ethat this may not work as well with small images. I do this with Multiple backgrounds. Se i need to load 10 BG's all at 960x480

    Do you run into memory issues on this scene? I have a game that I was trying to do all in one scene but the memory was right at the edge of crashing due to too many background images (at least that's what it seemed like).
  • CaptFinnCaptFinn Member Posts: 1,828
    why 1024x768 images on a iphone 4
  • PhoticsPhotics Member Posts: 4,172
    I was wondering why GameSalad even does this. What if we don't want our images to pre-load?

    But yeah... blank images are a problem. I don't notice this in BOT because the game fades to black during scene transitions.
  • StuartYStuartY Member Posts: 134
    Jeffnichols said:
    why 1024x768 images on a iphone 4

    Simply because they're large images that will take a lot of memory to load.
    LudwigHeijden said:
    Perhaps it helps if you also use the interpolate trick for timers?

    Just tried it, gives exactly the same performance as using timers. Maybe this would change if there were more timers and behaviours flying around, but for simply loading the images it doesn't seem to do anything.

    So - at the end of all this fun and games, I've come to the conclusion that I'll probably use the timer technique for my menu screen and not bother with it the rest of the time, as most of my objects remain the same from one level to the next. It would be interesting to know whether any of you who do use it have experienced noticeable "white squaring" at the start of levels in a "real" game situation - obviously, my test had a pretty huge amount (48mb) of images.

    In summary:

    Timers work, but images take some extra time to load - myth confirmed
    Using the method but not using timers doesn't give any appreciable advantage - myth busted
  • AppsRacKAppsRacK Member Posts: 346
    wow got some nice reading here. I've got one question though. When you use timer do you use the "change image behavior" or the "change attribute self.image" behavior?
    Thanks.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    you would use change attribute self image. but we cant do that till the 0.9.3 fix is out :(
  • AppsRacKAppsRacK Member Posts: 346
    oic thats why i didn't notice any changes in loading time. Got another question again (last one for this topic heheh). Should i use the "Timer" attribute or the "self.time>.01" method. Thanks guys.

    edit: oops sorry i think i found my answer. Thanks to TSB GSHelper vids. Damn i love that site. If i manage to have a big sale on my upcoming game i'll definitely support his product.
  • PhoticsPhotics Member Posts: 4,172
    I can't test it now, but I'm thinking of this future test...

    What if a Rule was used instead of a timer?

    If self.image ≠ self.name
    Then change self.image to self.name

    This way, I can quickly copy that instanced actor and only need to rename the actor "picture.png" to use the right image... and the rule would solve the problem of disappearing backgrounds.

    The problem is that the extra rules would eat performance.
  • StuartYStuartY Member Posts: 134
    JohnPapiomitis said:
    you would use change attribute self image. but we cant do that till the 0.9.3 fix is out :(

    I've been using the change attribute self.image with 0.93 - I hadn't heard there was a problem with it, seems to work for me.
  • PhoticsPhotics Member Posts: 4,172
    StuartY said:
    I've been using the change attribute self.image with 0.93 - I hadn't heard there was a problem with it, seems to work for me.

    The rule is broken though — self.attribute cannot be used as a condition.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    StuartY said:
    I've been using the change attribute self.image with 0.93 - I hadn't heard there was a problem with it, seems to work for me.

    You can't use self.image in a rule - as in when self.image contains ...

    you can still use it in a behavior such as change attribute
  • StuartYStuartY Member Posts: 134
    scitunes said:
    You can't use self.image in a rule - as in when self.image contains ...

    you can still use it in a behavior such as change attribute

    I see - great fun trying to switch smoothly between animations etc. then.
  • MagoNicolasMagoNicolas Member, PRO Posts: 2,090
    So, to make this Work,
    I need White Square, and make them Change image within a timer, lets say, 1 second (I Will change a lot of hidden images, not the images that are shown)

    But Change image preloads it?

    SO How Can I change the image?

    Cheers.
  • StuartYStuartY Member Posts: 134
    Mago, use change attribute self.image to WHATEVER.png
Sign In or Register to comment.