Page MenuHome

Dependency graph update_post handler trigger maximum recursion depth error
Closed, ArchivedPublic

Description

System Information
Operating system: Linux Ubuntu 64bits
Graphics card: /

Blender Version
Broken: Blender 2.8, 2019-05-25
Worked: Blender 2.8, 2019-04-30

Short description of error
When multiple addons append their own depsgraph_update_post handler then it causes a maximum recursion depth error

Exact steps for others to reproduce the error
here a simple code that illustrate the issue

import bpy
from bpy.app.handlers import persistent

@persistent
def scene_update(scn):
    obj = bpy.context.view_layer.objects.active
    if obj is not None:
        print(obj.name)

@persistent
def scene_update2(scn):
    pass
        
bpy.app.handlers.depsgraph_update_post.append(scene_update)
bpy.app.handlers.depsgraph_update_post.append(scene_update2)

This code add a new handler that print the active object's name when the selection change. The code works correctly but if another handlers is appended then clicking on the cube of the default scene print it's name dozens of times and sometimes triggering a maximum recursion depth error. Seems there is no issue when selecting the light or the camera.

Details

Type
Bug

Event Timeline

I cannot reproduce the issue using the given code.

However, in general you should protect yourself against recursions when using these handlers afaik.

Brecht Van Lommel (brecht) lowered the priority of this task from Needs Triage by Developer to Needs Information from User.May 29 2019, 1:52 AM

I can't reproduce recursion depth errors with this Python script, and it's not clear to me how it could happen here.

What are the exact steps to reproduce this problem? Just run the script and select some objects in the viewport?

Thanks for the feeback.

I can confirm that theses steps are not enough to reproduce this error. The initial issue was raised on my own addon's github and concern a conflict with another addon that also use a depsgraph_update_post handler. My addon works correctly as it but raise a recursion depth error only if the other addon is enabled. I'm trying to isolate the issue because I don't undersand what's wrong in my code, but the proposed snipped above fails only if my addon is still enabled.

So, I propose to close this task because for now I can't determine if there is something wrong in my code or in the depsgraph api.

For reference

Brecht Van Lommel (brecht) claimed this task.