[Solved]Weird Micro Stuttering Issue

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
Okapi
Newbie
Posts: 7
Joined: Wed Feb 17, 2021 11:02 am
Contact:

[Solved]Weird Micro Stuttering Issue

#1 Post by Okapi »

Hey Everybody
I've encountered this weird Micro Stuttering issue in my project, which I can't seem to fix.
I'm using this code in my project, which makes it so I can click on invisible Buttons in the background, which takes me to a label:

Code: Select all

screen room2():
        add "background" #This is a 20 frame animation background 
        
        
imagebutton:
        mouse "mouse2
        xpos 1585
        ypos 270
        idle "invisible_button.png" # empty PNG File (SIze:1140x450)
        hover "invisible_button.png"
        activate_sound "audio/sound3.wav"

        action [With(dissolve), Jump("label_1")]
        
label label_1:
        character1 "blablablablablablabla"
        call screen room2
The thing is, after I was testing stuff, I realised that after you pressed the button a couple times and jumping between the screen and the label, some weird Micro stuttering would occur. Before, the game would run at a smooth 60 FPS with 17,000 MS, but after a couple of Button presses, the reaction time would spike up to 27,000 MS frequently, which was noticeable due to the animated background. I suspected the animated background to cause some memory issues, so I've tried renpy.free_memory(), which unfortunately did not do anything. The image cache behaviour also wasn't unusual. I've also tested, if it is related to runtime, rather than button presses, but the micro stuttering would occur only after a certain amount of button presses. The problem is, that this stuttering carries on during the rest of the game, otherwise It would've been not that big of a problem. Of course, one could ask, why I would want to press that button rpeatedly anyways, but I'm planning on implementing several imegabuttons in that screen, so that the player can interact with many things in the background, which means that repeated button presses are bound to happen.
I've tried so many other things regarding image cache and image loading - none of it fixed the stuttering, so I feel like it has nothing to do with that, but I'm not super experienced with coding in general.
I'm hoping somebody could help me here
Thank you in advance
Last edited by Okapi on Sat Mar 20, 2021 8:18 am, edited 1 time in total.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3794
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Weird Micro Stuttering Issue

#2 Post by Imperf3kt »

You're calling the screen then jumping back to the label, from which you call the screen again, and this is causing the call stack depth to grow.
You should probably consider adding a return somewhere, to break out of the cycle.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Okapi
Newbie
Posts: 7
Joined: Wed Feb 17, 2021 11:02 am
Contact:

Re: Weird Micro Stuttering Issue

#3 Post by Okapi »

Imperf3kt wrote: Fri Mar 19, 2021 9:52 pm You're calling the screen then jumping back to the label, from which you call the screen again, and this is causing the call stack depth to grow.
You should probably consider adding a return somewhere, to break out of the cycle.
You're a saint :D. This was indeed the solution
I replaced the "Jump label" imagebutton action with a "ShowMenu" action and instead of call screen at the end of the label I just used return.
This solved the issue.
Thank you again :D

User avatar
m_from_space
Miko-Class Veteran
Posts: 974
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: [Solved]Weird Micro Stuttering Issue

#4 Post by m_from_space »

@Okapi
You can just use a "button" for invisible button areas, don't have to use a transparent image.

Post Reply

Who is online

Users browsing this forum: No registered users