Fix T103101: random Cycles animation rendering freezing up the application

This commit is contained in:
Brecht Van Lommel 2022-12-14 19:47:21 +01:00
parent 4121e32edd
commit 56237f33a1
Notes: blender-bot 2023-02-14 03:52:45 +01:00
Referenced by issue #103671, Regression: Memory leak: Something with materials slots
Referenced by issue #103372, Memory leak when adjusting material properties in Rendered view
Referenced by issue #103101, Cycles Crash on random frame in Blender 3.4
Referenced by issue #102967, 3.4: Potential candidates for corrective releases
1 changed files with 8 additions and 3 deletions

View File

@ -1046,14 +1046,19 @@ bool RE_engine_render(Render *re, bool do_all)
re->engine = engine;
}
/* create render result */
/* Create render result. Do this before acquiring lock, to avoid lock
* inversion as this calls python to get the render passes, while python UI
* code can also hold a lock on the render result. */
const bool create_new_result = (re->result == nullptr || !(re->r.scemode & R_BUTS_PREVIEW));
RenderResult *new_result = engine_render_create_result(re);
BLI_rw_mutex_lock(&re->resultmutex, THREAD_LOCK_WRITE);
if (re->result == nullptr || !(re->r.scemode & R_BUTS_PREVIEW)) {
if (create_new_result) {
if (re->result) {
render_result_free(re->result);
}
re->result = engine_render_create_result(re);
re->result = new_result;
}
BLI_rw_mutex_unlock(&re->resultmutex);