Fix USD Export crash with complex scenes, due to race condition during depsgraph building. #113537

Merged
Bastien Montagne merged 1 commits from mont29/blender:tmp-usd-fix-deg-export-crash into blender-v4.0-release 2023-10-12 19:10:46 +02:00
1 changed files with 18 additions and 7 deletions

View File

@ -314,13 +314,13 @@ static void export_startjob(void *customdata,
}
G.is_break = false;
/* Construct the depsgraph for exporting. */
if (data->params.visible_objects_only) {
DEG_graph_build_from_view_layer(data->depsgraph);
}
else {
DEG_graph_build_for_all_objects(data->depsgraph);
}
/* Evaluate the despgraph for exporting.
*
* Note that, unlike with its building, this is expected to be safe to perform from worker
* thread, since UI is locked during export, so there should not be any more changes in the Main
* original data concurrently done from the main thread at this point. All necessary (deferred)
* changes are expected to have been triggered and processed during depsgraph building in
* #USD_export. */
BKE_scene_graph_update_tagged(data->depsgraph, data->bmain);
*progress = 0.0f;
@ -450,6 +450,17 @@ bool USD_export(bContext *C,
job->depsgraph = DEG_graph_new(job->bmain, scene, view_layer, params->evaluation_mode);
job->params = *params;
/* Construct the depsgraph for exporting.
*
* Has to be done from main thread currently, as it may affect Main original data (e.g. when
* doing deferred update of the viewlayers, see #112534 for details). */
if (job->params.visible_objects_only) {
DEG_graph_build_from_view_layer(job->depsgraph);
}
else {
DEG_graph_build_for_all_objects(job->depsgraph);
}
bool export_ok = false;
if (as_background_job) {
wmJob *wm_job = WM_jobs_get(