Page 1 of 1

[SOLVED] Erratic slowing down/juddering

Posted: Mon Apr 13, 2020 6:55 pm
by randomnovice
Hi folks,

Could anyone help me figure out why this little beginning-of-a-game slows down cumulatively but erratically?

Additional:
- To see the slowing down: try new game and then click the cross then tick with any side panel a few times. After about thirty seconds you'll see it slow to a crawl... then recover and resume at a decent pace for a bit??
- It also sometimes takes a few seconds to run the quit command, even bringing up the spinning coloured wheel (on a Macbook).
- I know it's a strange/silly game. It's for my little ones.
- I know it doesn't do much yet.
- You can turn off the annoying voice if you click the audio button top left.
(- If you're not hearing an annoying voice anyway, it will only be playing if you're connected to the Internet.)

As always, massively appreciative of the awesome & wise community here. Thanks!

EDIT: Solved it myself and learnt a bit on the way!

The offending problem was in the function drawbuttontext as I was creating new fonts every frame:

Code: Select all

local font = love.graphics.newFont("fonts/heading.ttf", height*0.6)
I scaled using the inbuilt printf instead of creating a new scaled font and that smoothed things out dramatically.

I can also force garbagecollect() to run in the update to keep things ultra smooth... good to know!

Re: Erratic slowing down/juddering

Posted: Tue Apr 14, 2020 11:48 pm
by pgimeno
I've tried taking a brief look, but the code is big. I've found nothing standing out.

Re: [SOLVED] Erratic slowing down/juddering

Posted: Wed Apr 15, 2020 8:00 am
by randomnovice
Thanks for taking a look. I didn't know about the function...

Code: Select all

print(garbagecollect("count"))
...before trying to solve this one so that was a good learning curve. That showed up a sharp increase in work for the GC over time and I think it was mostly down to the function drawbuttontext because it created a local font to get rid of every single frame (also didn't know I really shouldn't do that!).