Image set in the compositor not taken in account by the pre render handler - blocking us in prod


I’m developing an add-on to write logos and additional information on rendered images. This is an important need for our current and upcoming productions.
In order to have it as little intrusive as possible I don’t want to introduce a new Render button anywhere (cause we already have several renderer add-ons) so I base it on the handlers. I then set up a small compositing graph that is evaluated at every rendered frame and produces the final image. In code (see add-on below) I change the overlaid image of the Input Image node at every frame in the pre render handler.

Note that I can’t use an image sequence in my final script since each of these overlaid images would be created in script (with Pillow) in the same handler. So having an image changed in the handler is mandatory.

… But it appears that when we do so there is a kind of “latency effect” (or very possibly a bug) that makes each overlaid image appear… too late! They are pasted on the next frame, not on the one they are supposed to be.
When we activate the Metadata information on the rendered images we clearly see the offset (text in red is from the overlaid image, metadata frame index is at the left bottom of the image):

So the issue is that the image set at each frame in the Input node is not updated / taken into account at the right time.

  • Does someone know if there is a kind of “update graph” function to call somewhere?
  • Is it a bug?
  • Else?

I provide here a whole repro context (script / scene / data):
To use the script and see the issue:

  • Open the provided scene, load the script, in the 3D View go to the Debug_BugRenderHandlers addon and press Create Handlers. Then press Ctrl + F12 to do the rendering.

System Information
Operating system: Windows 10
Graphics card: GeForce GTX 860M (also tested on 960)

Blender Version
Broken: 2.82, 2.83 alpha 8751af6d1902
Worked: not found

Thank you very much for any tip or help


Ok, one of the TDs I’m working with eventually came with a turnaround. Simple and smart.

In the Pre Render function my approach was to switch the Input Image node image from one to the other like this (line 110 of the provided script):

# previous code, not working (creating an offset of 1 frame): 
image =
compoNodeInput = scene.node_tree.nodes["ImageToComposite"]
compoNodeInput.image = image

# new working code:
image =
compoNodeInput = scene.node_tree.nodes["ImageToComposite"]
compoNodeInput.image.filepath = image.filepath

This changes everything! And now the script is working!
(but still, there is a strange and hard to explain behavior with the previous code)

Thanks Romain, thanks all

1 Like