Increasing lag with continued gameplay

Discussion in 'Technical Discussion' started by stevinz, Oct 24, 2015.

  1. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    Lately I have been having issues with several games that make use of gameplay actions to change the way the character behaves. I have been noticing with extended gameplay my games start to get laggier and laggier the longer the game goes on. I have been playing with decreasing action durations but in some cases that doesn't seem to make a difference.

    Anyone else experiencing lag onset in any of their games?
     
  2. Machine Rises

    Machine Rises Serious Boxer

    Joined:
    Sep 25, 2015
    Messages:
    591
    Likes Received:
    834
    More of a question for support@buildbox.com but off the top of my head I would check file size. Do you have any large images that you could resize? Any unused images or music? How many atlases? Think of all the ways you can optimize. Do you have a lot of lighting effects? It could be a myriad of things.
     
  3. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    Yes I thought I would talk to support once I was out of ideas. Still troubleshooting myself. Images are very small, only one atlas. No unused images, no sound or music. No lighting effects. I have the back delete threshold set to 360, sides to 1000. Average scene length is around 1500 pixels. I know it could be a lot of things...

    It does seem specifically to be a problem with collecting actions over time. I was wondering if anyone else has had similar issues.
     
    Last edited: Oct 25, 2015
  4. Machine Rises

    Machine Rises Serious Boxer

    Joined:
    Sep 25, 2015
    Messages:
    591
    Likes Received:
    834
    Hmm yeah that doesn't sound like a crazy project. I would definitely email support with all details and see how they can help pin point the issue.
     
    stevinz likes this.
  5. Phill Mason

    Phill Mason Serious Boxer

    Joined:
    Sep 25, 2015
    Messages:
    880
    Likes Received:
    721
    Hey @stevinz, I've got quite a few actions throughout some of my scenes and have played it like a Billion times (not exaggerating) and haven't noticed any lag. All my actions are simply triggers for other. Off the top of my head, I don't think I've used any gameplay changes, so it sounds like the issue is isolated to gameplay actions only?!??!

    Have you tried copying your BBdoc and play around with the copy by removing the first major gameplay change and continue playing to see if you experience the same lagging up to a certain point? Are you resetting gameplay with another action? I seem to remember there's a bug where the gameplay action doesn't reset after duration is finished. Also, do you have more than one action kicking off in the same scene? If so, perhaps the first action is not correctly finishing if a second action is being triggered, even though I don't think the second action will trigger if the first one is still running. As @Machine Rises mentioned, lots of things at play here, so pulling apart a copy is probably the quickest way for you to get to the problem.
     
    stevinz and Christoph like this.
  6. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    Do you get lag on your device or on the computer? I noticed a lot of lag on older devices with my game and it had to do with a lot of elements moving around at the same time (mostly particles floating around). I had to reduce the effects to make it compatible with iphone 5 and 4s. You can actually read through the reviews of Phases to see similar behavior. This is definitely a Buildbox problem because other games like Crossy Road or Geometry Dash have no problems running on those devices. Notice, I also have gameplay actions from time to time and didn't had problems with them...
     
    stevinz likes this.
  7. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    @Phill Mason @Christoph ... I've spent some time playing with it this morning. I have isolated many scenes and ran some tests. It definitely seems gameplay action related. So far as I can tell, when you continue to collect gameplay actions they tend to stack up even though every new gameplay action replaces the last one you've collected. So if the duration is set higher than 4 or 5 seconds over a period of 20-30 scenes the game starts to slow down (on any device, including my MacBook and iPhone 6) as it seems to be processing an ever increasing collection of gameplay actions. I had a similar issue before with collecting many actions (of type "None") but solved it by changing their duration to ".01". Problem is: if you're changing gameplay a lot and need the change to be permanent until a new action is collected, the only current available option is to use a large duration of like 100+. Otherwise the new gameplay type might run out before the character makes it to the next gameplay action.

    After a lot of playing around the best solution I've come up with so far is to keep the duration high but set the animation type to "Powerup - Replace - Single Play". By doing this it seems to clear out old gameplay actions, no matter the duration, once the animation passes the back delete threshold. It still seems to get a little laggy after a while, but better than before.

    Again, if anyone has experienced a similar issue with gameplay actions and has come up with a solution I'd be happy to discuss it.
     
    Phill Mason and Christoph like this.
  8. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    This sounds as if the animation keeps playing in the background and never stops... (when looping the action animation during a longer time). It could be related to the bug where the gameplay action doesn't get set back to normal after the time is up.
     
    stevinz likes this.
  9. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    @Christoph Agreed, it does seem like the case. Ironic since I'm not actually using anything for the action animation itself. I have found changing the default "90" frames of a blank action to "0" frames gives some performance boost as well. Although, that part could be in my head, haha. I plan on emailing support after some more playing around...
     
  10. Machine Rises

    Machine Rises Serious Boxer

    Joined:
    Sep 25, 2015
    Messages:
    591
    Likes Received:
    834
    Even a game like bounce I noticed can get very laggy. There are parts where littl balls are spawning. If you sit and bounce while they spawn eventually so many will spawn that the game gets super laggy. But as long as you keep going there's not a problem.

    Are your scenes really long? It's possible if they are shorter that could have an effect but I don't know for sure. Only speculation. But I do know that the bigger the file the more possible issues there can be. For video for example if you have a clip that is let's say an hour long then you risk the chance of the audio going out of sync after a while then you have to trouble shoot. So perhaps also look at your structure and see if there's anything you can make smaller, shorten, etc.

    But if there is some coding issue where the actions don't completely reset an that's causing the problem, then that could be a great fix from the BB technical team for everyone. Let us know what they say.
     
    superjack765 likes this.
  11. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    @Machine Rises Yeah I have noticed lag before with the use of too many objects / lighting on scenes. Thats not the case in this game, though. Its very minimal with not many objects or animation. The scenes range from 1200-1800 pixels in length so not really an issue there either. Very small and simple game with no sounds or lights or animations at this point.

    I have ran through problem levels with the gameplay actions removed and they run great indefinitely with no lag issues. Thats how I know at this point its gameplay action related. I will keep everyone posted with any new information I find and will relay anything useful I learn from the BuildBox team.
     
  12. Phill Mason

    Phill Mason Serious Boxer

    Joined:
    Sep 25, 2015
    Messages:
    880
    Likes Received:
    721
    @stevinz, the stacking up accumulative actions sounds like the most plausible issue. I'm taking notes :)
     
  13. sappz

    sappz Guest

    Joined:
    Oct 5, 2015
    Messages:
    25
    Likes Received:
    10
    I've experienced these kind of issues with many other different kind of softwares before and my solution was to always uninstall and re-install the software. Maybe that will fix the issue.
     
    superjack765 likes this.
  14. David D

    David D Boxer

    Joined:
    Sep 28, 2015
    Messages:
    91
    Likes Received:
    37
    I am also experiencing lag with my current impossible horizontal style game. I get some heavy lag during a few of the scenes when previewing. I am hoping it will be limited to preview and not during actual mobile play, but I haven't tested it yet. @stevinz please let me know what you discover about the topic. Thanks!
     
  15. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    In my experience, the possibility that it lags on device is much higher than that it lags in the preview. It mostly depends on your computer, but normally, computers are faster than mobile devices. As I said somewhere else, you can't use too much effects and particles.
     
  16. stevinz

    stevinz Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    169
    Likes Received:
    142
    I agree with @Christoph on the fact that preview seems to lag less than games installed on devices. I would guess that since the buildbox source is precompiled, there is no performance loss running your game through preview. My MacBook runs the games much easier than my iPhone 6. On my Windows machine I noticed more lag, but I figured that's just Windows being Windows haha.

    There are many causes that can contribute to lag. Too many objects / lights / animations / sounds / atlasses / etc could all cause performance issues... This particular thread, however, was created because I was noticing an onset of lag over time on a pretty simple project that should be able to run without any issues. I will continue to update this thread if / when I learn anything new on the subject.
     
  17. darren

    darren Avid Boxer

    Joined:
    Sep 25, 2015
    Messages:
    134
    Likes Received:
    58
    test early and often!
     
    Simon Crack and Christoph like this.
  18. mike_davison

    mike_davison Boxer

    Joined:
    Sep 25, 2015
    Messages:
    2
    Likes Received:
    0
    This problem was worse on older phones, but is one of the reasons there aren't too many of those spawner levels :) It's quite a lot of physical objects for the processor to deal with. Seems to affect older Android devices worse than iOS too
     
  19. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    I did some test levels with tens of actions. Not necessarily gameplay actions. I tested it on an older device (iPhone 4s) and it got very laggy when the character was changing from one scene to another. It seems that it needs a lot of processor to load the actions.
     
  20. Jayson

    Jayson Boxer

    Joined:
    Oct 19, 2015
    Messages:
    85
    Likes Received:
    58
    I think I can add something on this.

    Imagine a glass. Hold it and pretend it has beer in it. Nah, don't mind the beer.
    The sides of the glass are your "side delete threshold" while the bottom is the "back delete threshold". Anything that touches the glass gets zapped from the memory.
    Now imagine your buildbox gameplay with the glass. Point the glass on the direction of your gameplay (game direction).

    Now, do you have objects/power ups/etc that "escape" the glass? They bog up the memory because they are not destroyed.

    How could I explain this better? haha

    I realized this when I was having the same issue with my game.
    My game direction is downward, and alot of physics objects fall down. There would come a time, no matter what I optimize, that the game would lag.

    The reason was those physics objects(or any object) are still active in the memory. In a downward game, the back delete is on top(Imagine the glass upside down).

    Solution?

    I made the objects "fall" up so they can be deleted from the memory. No more lags since then.

    I hope my GLASS theory helps. :D


    To sum it up:

    If your game direction goes right, check for objects that travel to the right. Chances are they stay there unseen, and as more of them accumulate, they eventually bog the memory and cpu down.

    If your game direction goes up, check for objects that travel up... so on.
     
    Last edited: Oct 30, 2015

Share This Page