"Maximum recursion depth exceeded" when calling screen

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
BrotherKerubim
Newbie
Posts: 11
Joined: Sun Oct 31, 2021 2:09 pm
Contact:

"Maximum recursion depth exceeded" when calling screen

#1 Post by BrotherKerubim »

Hi! Keep getting this error from time to time in different screens. Looked through traceback but still have no idea how to fix it.
I would greatly appreciate some help!
1.PNG
Attachments
traceback.txt
(111.95 KiB) Downloaded 30 times

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#2 Post by _ticlock_ »

BrotherKerubim wrote: Mon Dec 05, 2022 2:16 am
Is it a free-roam interface? If label cabins_level_door1 looks the same as cabins_level_hub, then with each move you add to the stack with Call action but never remove it from stack.

Likely, what you want is to use Jump action instead of Call action.

BrotherKerubim
Newbie
Posts: 11
Joined: Sun Oct 31, 2021 2:09 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#3 Post by BrotherKerubim »

_ticlock_ wrote: Mon Dec 05, 2022 12:32 pm
BrotherKerubim wrote: Mon Dec 05, 2022 2:16 am
Is it a free-roam interface? If label cabins_level_door1 looks the same as cabins_level_hub, then with each move you add to the stack with Call action but never remove it from stack.

Likely, what you want is to use Jump action instead of Call action.
Hi! Fixed it, but not sure if it helped.
It appeared again in other place:
traceback.txt
(106.08 KiB) Downloaded 25 times
After I chose to ignore, it happened again on other screen (where I've already changed Call() to Jump() )
traceback 2.txt
(106.24 KiB) Downloaded 26 times
2.PNG

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#4 Post by _ticlock_ »

BrotherKerubim wrote: Thu Dec 08, 2022 2:40 am
Did you use the old save? In your old save you likely have a long call stack that eventually may result in a recursion depth error.

Open console (Shift+O) and type renpy.get_return_stack() just to confirm that it is not coming from the call stack.

BrotherKerubim
Newbie
Posts: 11
Joined: Sun Oct 31, 2021 2:09 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#5 Post by BrotherKerubim »

_ticlock_ wrote: Thu Dec 08, 2022 12:18 pm
Nope, I start a new game each time I try.
I guess you were right, renpy.get_return_stack() was filled with 10-15 calls.
I missed to change Call() to Jump() in one screen.

After fixing it I got slightly different error.
traceback.txt
(4.53 KiB) Downloaded 37 times

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#6 Post by _ticlock_ »

BrotherKerubim wrote: Fri Dec 09, 2022 12:36 pm Nope, I start a new game each time I try.
I guess you were right, renpy.get_return_stack() was filled with 10-15 calls.
I missed to change Call() to Jump() in one screen.

After fixing it I got slightly different error.
The last error you get is likely caused by the same problem.

Likely, the recursion happens somewhere else. I don't see any direct problems that could lead to recursion(besides using Call action)

What is "ship_deck.rpyc", line 14, in script? Is it also call screen some_screen?

What function scene does? I'd recommend renaming it to avoid confusion with scene statements.

Check that you don't have functions that indirectly call themselves or variables that indirectly use themselves.

BrotherKerubim
Newbie
Posts: 11
Joined: Sun Oct 31, 2021 2:09 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#7 Post by BrotherKerubim »

_ticlock_ wrote: Fri Dec 09, 2022 2:29 pm What is "ship_deck.rpyc", line 14, in script? Is it also call screen some_screen?
It calls function scene_deck() which starts playing background noise and shows a layered scene with a certain offset of its images. Also it defines default transition for this scene.
1.PNG
_ticlock_ wrote: Fri Dec 09, 2022 2:29 pm What function scene does? I'd recommend renaming it to avoid confusion with scene statements.
It does almost the same as default scene but it defines what background noise file should start or keep playing and shows transition.
2.PNG
These are definitely not the best code examples, but I don't see anything that would cause the discussed matters.

_ticlock_ wrote: Fri Dec 09, 2022 2:29 pm Check that you don't have functions that indirectly call themselves or variables that indirectly use themselves.
I looked trough all functions, images and transitions defined by me, didn't see any noticable recursions. I hoped there is some way to catch what exactly causes problem, without all this guessing. Something like renpy.get_return_stack() but for cases like this.

User avatar
_ticlock_
Miko-Class Veteran
Posts: 910
Joined: Mon Oct 26, 2020 5:41 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#8 Post by _ticlock_ »

BrotherKerubim wrote: Fri Dec 09, 2022 4:26 pm
One way is to localize the code where the problem occurs. As I understand the error occurs occasionally and not specifically at a particular point which is what is making it hard to track.

Looking at the traceback, one thing you can find in common. Repetition of the following lines:
File "C:\Users\Goka\Downloads\WetSand-0.2.7-win\WetSand-0.2.7-win\renpy\display\transform.py", line 747, in render
return transform_render(self, width, height, st, at)
File "accelerator.pyx", line 187, in renpy.display.accelerator.transform_render
File "render.pyx", line 266, in renpy.display.render.render
Probably, someone can point out where to start looking based on this.

Likely, the problem is related to the rendering of a displayable. I suggest double-checking your images, looking at the image declarations, transform declarations. For example, declaration of ship_deck_sea_horizon_4, ship_deck_sea_bg4_pos, blurred

It is also possible that the error in the displayable that not even related to the current statement.

BrotherKerubim
Newbie
Posts: 11
Joined: Sun Oct 31, 2021 2:09 pm
Contact:

Re: "Maximum recursion depth exceeded" when calling screen

#9 Post by BrotherKerubim »

_ticlock_ wrote: Fri Dec 09, 2022 5:52 pm
Okay, I think I got it.
I put this line in \renpy-8.0.3-sdk\renpy\display\transform.py
1.PNG
to log what's going on in there and got my game crashed with recursion error.
log file was overfilled with logs like this
2.PNG
I checked what's in ('renpy/common/00definitions.rpy', 45) and there was a truecenter declaration
I remembered that I used it in my custom scene() function
3.PNG
So problem was that I misunderstood how default arguments work in Python. at list was not created each time anew when the function was called, but continued to accumulate truecenter instances in itself.

I hope the way I solved the problem will help someone else. Thanks _ticlock_, you helped a lot!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Majestic-12 [Bot]