Performace assistance appreciated.

Hi @bgmadclown (and all),

I really don’t know what my most used transition call is for sure.

I would really love to check some details of what’s running, but if I select everything from transition._transitionTable then all I get is a list of tables, so if anyone knows how I can interrogate this information further it’d be awesome to hear from you.

Obviously I see lower FPS with more enemies on screen and I see the transitions go up too - so the correlation is there.

On a side note I became a father yesterday so my focus is elsewhere just for now, but please be assured I’m going to persevere with this issue until I’ve resolved it. Especially as I intend to make more games in future, and don’t want to fall into the same trap!

I’m happy to paste my AI code with the transitions therein, but I think this will have limited usefulness, as, depending on what other interactions occur, knock on effects will incur other transitions too. Hence ideally gleaning further info from the transitions tables.

All the very best and thanks to all who are taking the time to offer up information and solutions!!!

1 Like

Congratulations on being a father! :slight_smile:

When all things settled, without diving deep into the tables, you should easily be able to tell us where and when you call those transitions. No exact numbers are needed but you should definitely keep track of your calls. It could easily get out of hand.

2 Likes

Thank you!! :smiley:

Ok I will trace some code and post what I find.

All the best,

Nick

1 Like

@DigiNick
Sorry I’m so late to the conversation.

This problem is familiar to me. Do you by any chance have objects that might “die” in the middle of a transition?

@DigiNick
Congratulations on fatherhood! Get used to coding with one hand and rocking with the other.

Your current woes sound like a mystery problem I encountered - it is actually the most frustrating thing I dealt with as a Corona/Solar programmer . It was a memory leak involving transitions and timers in complicated multi-object life and death simulations. I’m assuming there is object “death” in your app as I see guys walking around with swords :wink:

OK, basically it goes like this: You have a bunch of “living” things interacting with transitions and timers. These living things can die and leave their transitions and timers without references to control them. This happens especially in scenarios where lots of things are interacting and lots of things can kill you. You might set up everything logically and programmatically correct but the disconnect is that Solar2D is frame-based and your timers and transitions are time-based.

Possible solutions:

  1. As mentioned above, you can reduce the transition and timer load by using a single enterFrame to control multiple objects. I use one enterFrame to control movement for thousands of objects (non-physics).

  2. Make sure you tightly control the death sequences of your objects - especially make sure they can’t die more than once. The final death collision could trigger multiple transitions and you would never know.

  3. If you are pausing and restarting many transitions or timers - it can lead to some of the symptoms you’ve described.

  4. If you use conventions like

    object.transition = transition.to( )

    that can be problematic when the object dies

  5. This is time-consuming but it was the ultimate solution for me. Add every transition and timer to a table so you can track them and cancel them manually when the object is killed, just to make sure they are deleted. You can then also delete expired and cancelled transitions and timers.

*If this sounds promising, I can give you more details. In the meantime, I would need to see the code you use to call timers and transitions.

So Nick, a lot of people show up on the forums and ask for help but aren’t willing to put in the work. You have shown us that you are willing to put in the work and that’s why we are all cheering you on. We’ve all been on the precipice where you find yourself now - thoroughly frustrated, feeling defeated and wondering if we can really do this. The answer for you is “yes you can”. If you have the desire and commitment you can make this happen - you’ve shown the fortitude to make it this far. Will it be easy, no, it will be taxing and frustrating and utterly deflating but you will emerge on the other side as a stronger more confident programmer. @roaminggamer helped me out a ton when I was first starting and I like returning that energy to the community now - someday it might be you giving back.

Personally, I’ve been heartbroken to throw away a project I had put many hundreds of hours into and start it over from scratch but then I realized that the first project was really just a sketch. As an artist, I might do a ton of sketches before I tackle a larger project and I’ve found that mindset helpful in programming.

In business there is a theory called “sunk cost” where people tend to overvalue the things they’ve already invested time or money in - it’s one of the reasons people stay in bad relationships. That’s the theory that led me to start fresh with the project I mentioned above and I’m glad I did. Whether or not you do decide to restart this project or future projects, know that it is always a valid option.

Enjoy your new journey into fatherhood and we’ll be here to help with your journey into programming whenever you are ready

– Jonathan (sporkfin)

2 Likes

Dear Jonathan et al,

Firstly thank you so much for taking the time to write such a lovely post!
If ever a coder needed morale support they are certainly in the right place here aren’t they?!
Your friendly words have not fallen on deaf ears and I really appreciate your sentiment and the time taken to assist me both technically and inspirationally!

To be sure, being a parent at these early stages certainly is tiring, and whilst I have had some time to code as still furloughed until the end of this month, I haven’t really been in the mindset to as much as before, which I’m sure is understandable.

Having said that, I have made progress, so much so as I think I’ve resolved the most severe FPS drops and am now actually ready to publish to the app store after a couple more small tweaks to the content.

So before I sign off on the last set of points that I’ve altered to achieve my goal, I’d like once more to thank everyone who has taken the time to comment on this thread. Absolutely everything mentioned has given me food for thought, and helped me attain a level of Solar2D competency superior to two months ago, and also boosted my confidence to start project number 2 - albeit not immediately…! I also hope this will help others in similar situations in the future.

Final edits are:

  • Object pooling. After my initial successes with object pooling I continued to do so with more and more objects until I hit “breaking point”. Basically load times became unacceptable and I was doing it with images and sprites that were offering little or no benefit whilst playing. Even the simulator took ~10 secs or so to start up. So I removed some pools and left only those objects which are required simultaneously. All others which are loaded in game are added as sprite sheets, and therefore cached, providing acceptable performance even if only 25ms between the loads.

  • As mentioned in the post above, I removed timers on enemies at destruction. I do not know exactly how much difference this has made, but it made total sense to me when you mentioned it @sporkfin . I suspect it has helped the FPS over the long term instead of at specific events.

  • Reduced my transitions! As mentioned by @bgmadclown, I located the biggest offender: Footprints! Each enemy created a footprint image every step which faded out over 60 seconds - these were indeed creating a lot of additional overhead. Interestingly I tried NOT fading them out at all, which reduced the transitions, but still dropped the FPS substantially due simply to the amount of images on screen. I now use a timer to fade them out over 5 seconds after a 25 second delay, and all is good. If, with lots of enemies I notice similar issues, I shall reduce the delay, fade time, or seriously consider removing them from the game completely, as it’s eye candy only and does not affect gameplay.

In fear of repeating myself I’d like to sign off by thanking everyone again for your time. You really have made a difference to my project, future projects, and my love of the experienced coders in this community. I hope I too, can give something back at some point. I will post a link to my game when released, if anyone is interested!

Warmest wishes to you all,

Nick

:heart: :orange_heart: :yellow_heart: :green_heart: :blue_heart: :purple_heart:

3 Likes