Hello, I have built a c++ plugin in which I use the RenderDocument function with a render progress hook, pretty much like in the commandline example, and exposed the function to python via
pylib.InitModule("module_name", moduleFunctions, "Module Description")
My custom function takes the document and renderdata as arguments and works as expected: when I send my render command in the script editor or in a python plugin I can see the printout of the render progress.
Only, in some specific cases, the render hangs. For instance, if I render subdivision surfaces in Octane, with full motion blur on:
- "Render progress: 0%" is printed, then no further output comes from the render hook
- Octane info about exported materials is printed out as usual, but unlike the other times no update about rendering comes out
- The GPU is busy, as expected, but no image is written
- I see printouts about threads shutting down normally
- The GPU stops being used
- The VRAM is not emptied
- The application freezes
In the debugger, I can see that the internal RenderDocument function doesn't return, but I cannot see what it's really doing as I have no .pdb for the inner functions. I can see that the deassembly code is running a loop of some sort, but I am not proficient in assembly so that's it. There is no GPU nor CPU load
the RenderDocument line is quite standard:
RenderDocument(doc, data, RenderProgressHook, nullptr, bmp, RENDERFLAGS::EXTERNAL | RENDERFLAGS::NODOCUMENTCLONE | RENDERFLAGS::SHOWERRORS, nullptr);
I have tried using no RenderProgressHook, or other combinations of renderflags, tried to run on separate threads both in C++ and Python, and using clones rather than doc and renderdata directly, but the results are always the same.
I have tried to run the very code used in the sdk commandline render, even using commandlinerender.cpp as it is, the results are always the same:
- if the render is started inside the c++ plugin, during the C4DPL_COMMANDLINEARGS message, it succeeds
- if an Octane render with motion blur and subdivisions is invoked from inside python, either via exposed functions or plugin messages, it freezes
I realise this is kind contrived and I have ventured through a strange path, is there any insight from the community or devs that can help me to fix this issue? Is there any structural barrier that prevents from having a progress hook when python is involved? And in which way the RenderDocument function provided in the python SDK, though without render progress, manages to work around this apparent issue? Does its implementation differ significantly from the one in the commandline example or does it use the C++ SDK too?
Thanks for reading,
Paolo