Cleaning up scene - IMRender Result error (bke.lib_id_delete)
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 518
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the issue
After rendering a scene, and then using the `clean_up()` function, an error is issued:
> ERROR (bke.lib_id_delete): source/blender/blenkernel/intern/lib_id_delete.c:345 id_delete: Deleting IMRender Result which still has 1 users (including 0 'extra' shallow users)
Further, (maybe unrelated), but if ignoring this message and continuing to render the next scene, then at the time when the frames are written to disk this error is issued at the coco writer (`bproc.writer.write_coco_annotations()`):
> Warning! Detected output entries with duplicate keys and paths
### Minimal code example
```python
import blenderproc as bproc
bproc.init()
bproc.object.create_primitive('CUBE')
bproc.camera.add_camera_pose(bproc.math.build_transformation_mat((0,-2,0), (1.57,0,0)))
frames = bproc.renderer.render()
# bproc.writer.write_coco_annotations(...)
bproc.clean_up() # error occurs here
# doing some other rendering ...
```
### Files required to run the code
_No response_
### Expected behavior
No error
### BlenderProc version
v2.6.1
### More information
Seems to appear when (inside the clean_up function) the image render result is removed. I suppose it is deleted too early, and there is some kind of dependency on another object that should get first deleted?
```python
data_structure = getattr(bpy.data, 'images')
data_structure.remove(data_structure[0],do_unlink=True) # error appears here
```
Contributor guide
Research direction
Reproduce the minimal example on BlenderProc v2.6.1, focusing on bproc.clean_up() and the bpy.data.images removal shown in the report. Inspect the cleanup path alongside Blender's source/blender/blenkernel/intern/lib_id_delete.c:345, then test another render and bproc.writer.write_coco_annotations(). Done means cleanup emits no IMRender Result error and the later writer emits no duplicate-key warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100