I recently switched my daily driver from ZorinOS (Ubuntu-based) to Fedora 36 (KDE Spin) and cloned my project repository and tested it. However when I switched to fullscreen or scaled up the window dimensions the performance decreased, which I never experienced in ZorinOS. I also updated my drivers & system and disabled vsync but that didn't seem to fix it. Does anybody know about this?
Repo link: https://github.com/zerpnord/blockdash/
Lag spikes in Fedora 36 KDE
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Lag spikes in Fedora 36 KDE
- Attachments
-
- blockdash.love
- (496.12 KiB) Downloaded 138 times
Re: Lag spikes in Fedora 36 KDE
It looks like you have some memory leak (it uses more RAM each game), try checking if you are not creating images, shaders or other object more times
EDIT: I kept the game running while writing this comment and it allocated 1.1 GB of RAM
Last edited by Andlac028 on Wed Sep 21, 2022 7:00 pm, edited 3 times in total.
Re: Lag spikes in Fedora 36 KDE
Update: Running the game as super user seemed to fix the issue, but now the audio doesn't work and prints the following:
Code: Select all
error: XDG_RUNTIME_DIR not set in the environment.
Could not open device.
Re: Lag spikes in Fedora 36 KDE
After looking into your code, I found that you are frequently using love.graphics.setNewFont, which creates new Font each frame (this is CPU and memory intensive). See big warning on wiki page about creating objects in love.draw.
To solve this issue, use love.graphics.newFont once for font and save it somewhere and then use love.graphics.setFont like:
These are places using love.graphics.setNewFont: https://github.com/Zerpnord/BlockDash/s ... setNewFont
To solve this issue, use love.graphics.newFont once for font and save it somewhere and then use love.graphics.setFont like:
Code: Select all
FONT_NORMAL = love.graphics.newFont('something.ttf', 12)
-- your code ...
function someEntity.draw()
-- and in draw functions, use
love.graphics.setFont(FONT_NORMAL)
-- instead of love.graphics.setNewFont
-- more your code
end
Last edited by Andlac028 on Wed Sep 21, 2022 6:57 pm, edited 3 times in total.
Re: Lag spikes in Fedora 36 KDE
It seems like that's one of the issues but not the main factor, because when I ran sudo love . instead of love . it seemed to fix the majority but the audio was gone. That memory leak is probably caused by the asset manager, because it seems like I ran assets.load() everytime a game started. ThanksAndlac028 wrote: ↑Wed Sep 21, 2022 6:31 pm It looks like you have some memory leak (it uses more RAM each game), try checking if you are not creating images, shaders or other object more times Screenshot from 2022-09-21 20-30-18.png
EDIT: I kept the game running while writing this comment at it allocated 1.1 GB of RAM
Re: Lag spikes in Fedora 36 KDE
Is there a way to change the font size during loop? It's one of the main factors I used setNewFont().Andlac028 wrote: ↑Wed Sep 21, 2022 6:42 pm After I looked into code, I found that you are frequently using love.graphics.setNewFont, which creates new Font each frame (this is CPU and memory intensive). See big warning on wiki page about creating objects in love.draw.
To solve this issue, use love.graphics.newFont once for font and save it somewhere and then use love.graphics.setFont like:These are places using love.graphics.setNewFont: https://github.com/Zerpnord/BlockDash/s ... setNewFontCode: Select all
FONT_NORMAL = love.graphics.newFont('something.ttf', 12) -- your code ... function someEntity.draw() -- and in draw functions, use love.graphics.setFont(FONT_NORMAL) -- instead of love.graphics.setNewFont -- more your code end
Re: Lag spikes in Fedora 36 KDE
Re: Lag spikes in Fedora 36 KDE
In your case, you are mainly using constant size font, so just create more fonts on start with different sizes, like
Code: Select all
FONT_MINECRAFTIA_14 = love.graphics.newFont("fonts/Minecraftia-Regular.ttf", 14)
FONT_MINECRAFTIA_22 = love.graphics.newFont("fonts/Minecraftia-Regular.ttf", 22)
FONT_MINECRAFTIA_24 = love.graphics.newFont("fonts/Minecraftia-Regular.ttf", 24)
-- and then use
love.graphics.setFont(FONT_MINECRAFTIA_14)
-- instead of
love.graphics.setNewFont("fonts/Minecraftia-Regular.ttf", 14)
It is way better to create 50 fonts with different sizes on start, than new font every frame (that is 60 fonts per second with 60 FPS) like:
Code: Select all
FONTS_MINECRAFTIA = {}
-- create fonts with sizes from 10px to 50px
for size = 10, 50 do
FONTS_MINECRAFTIA[size] = love.graphics.newFont("fonts/Minecraftia-Regular.ttf", size)
end
-- and then use
love.graphics.setFont(FONTS_MINECRAFTIA[some_computed_font_size])
Last edited by Andlac028 on Wed Sep 21, 2022 6:57 pm, edited 2 times in total.
Re: Lag spikes in Fedora 36 KDE
Yes, it takes care of it, but you are just creating so huge amount of new fonts, that it can't keep up with it
You can use collectgarbage() to force garbage collector run (it is also called automatically), but it is good to solve the root cause of problem, as it also involves wasting CPU time, just by creating a ton of new identical fonts
Who is online
Users browsing this forum: No registered users and 10 guests