From f09d465a6da896e7e75ab34fa4e959ec3e48d2b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20T=C3=B6nne?= Date: Mon, 12 Jun 2023 14:21:50 +0200 Subject: [PATCH 1/2] Fix #108376: Copy from geometry to other node tree types resets shapes Socket shapes are used in geometry nodes to indicate field types. In other tree types (e.g. shaders) the socket shape is not touched at all. Since nodes can be copied from geometry node trees, we need to reset the socket shape when copying to a shader, compositor, or texture tree. Pull Request: https://projects.blender.org/blender/blender/pulls/108412 --- source/blender/editors/space_node/clipboard.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/blender/editors/space_node/clipboard.cc b/source/blender/editors/space_node/clipboard.cc index 5ed91cd4fbe..b3cdfbc3871 100644 --- a/source/blender/editors/space_node/clipboard.cc +++ b/source/blender/editors/space_node/clipboard.cc @@ -245,6 +245,13 @@ static int node_clipboard_paste_exec(bContext *C, wmOperator *op) { bNode *new_node = bke::node_copy_with_mapping( &tree, node, LIB_ID_COPY_DEFAULT, true, socket_map); + /* Reset socket shape in case a node is copied to a different tree type. */ + LISTBASE_FOREACH (bNodeSocket *, socket, &new_node->inputs) { + socket->display_shape = SOCK_DISPLAY_SHAPE_CIRCLE; + } + LISTBASE_FOREACH (bNodeSocket *, socket, &new_node->outputs) { + socket->display_shape = SOCK_DISPLAY_SHAPE_CIRCLE; + } node_map.add_new(&node, new_node); } else { From 7f9021a92f3d67d747531742d75bcfe4e2d9b0ab Mon Sep 17 00:00:00 2001 From: Ray Molenkamp Date: Mon, 12 Jun 2023 08:51:51 -0600 Subject: [PATCH 2/2] deps_builder: fix deadlock in idiff idiff sometimes locks up while shutting down when the CPU is oversubscribed. While blender does not rely on the idiff tool the tests that run on the CI environment do, which causes tests to occasionally fail due to a timeout. The root cause is a bit complex but can be found on the oiio tracker at https://github.com/OpenImageIO/oiio/issues/3851 This change fixes idiff by : 1- Shutting down the thread pool before the main function exits 2- Have the shutdown wait for the pool threads to actually join, to prevent the OS from forcefully terminating them while they could potentially still be holding a lock. --- .../build_environment/cmake/openimageio.cmake | 3 +- .../patches/oiio_deadlock.diff | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 build_files/build_environment/patches/oiio_deadlock.diff diff --git a/build_files/build_environment/cmake/openimageio.cmake b/build_files/build_environment/cmake/openimageio.cmake index 7e67485f53d..c0b50961f1e 100644 --- a/build_files/build_environment/cmake/openimageio.cmake +++ b/build_files/build_environment/cmake/openimageio.cmake @@ -106,7 +106,8 @@ ExternalProject_Add(external_openimageio CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR} PREFIX ${BUILD_DIR}/openimageio PATCH_COMMAND ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/openimageio.diff && - ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_3832.diff + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_3832.diff && + ${PATCH_CMD} -p 1 -N -d ${BUILD_DIR}/openimageio/src/external_openimageio/ < ${PATCH_DIR}/oiio_deadlock.diff CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${LIBDIR}/openimageio ${DEFAULT_CMAKE_FLAGS} ${OPENIMAGEIO_EXTRA_ARGS} INSTALL_DIR ${LIBDIR}/openimageio ) diff --git a/build_files/build_environment/patches/oiio_deadlock.diff b/build_files/build_environment/patches/oiio_deadlock.diff new file mode 100644 index 00000000000..cfaa6fdc3bc --- /dev/null +++ b/build_files/build_environment/patches/oiio_deadlock.diff @@ -0,0 +1,62 @@ +diff -Naur orig/src/idiff/idiff.cpp external_openimageio/src/idiff/idiff.cpp +--- orig/src/idiff/idiff.cpp 2023-06-07 07:47:42 -0600 ++++ external_openimageio/src/idiff/idiff.cpp 2023-06-07 09:46:47 -0600 +@@ -399,5 +399,6 @@ + + imagecache->invalidate_all(true); + ImageCache::destroy(imagecache); ++ default_thread_pool()->resize(0); + return ret; + } +diff -Naur orig/src/libutil/thread.cpp external_openimageio/src/libutil/thread.cpp +--- orig/src/libutil/thread.cpp 2023-06-07 07:47:42 -0600 ++++ external_openimageio/src/libutil/thread.cpp 2023-06-07 09:45:39 -0600 +@@ -151,9 +151,10 @@ + this->set_thread(i); + } + } else { // the number of threads is decreased ++ std::vector> terminating_threads; + for (int i = oldNThreads - 1; i >= nThreads; --i) { + *this->flags[i] = true; // this thread will finish +- this->terminating_threads.push_back( ++ terminating_threads.push_back( + std::move(this->threads[i])); + this->threads.erase(this->threads.begin() + i); + } +@@ -162,6 +163,11 @@ + std::unique_lock lock(this->mutex); + this->cv.notify_all(); + } ++ // wait for the terminated threads to finish ++ for (auto& thread : terminating_threads) { ++ if (thread->joinable()) ++ thread->join(); ++ } + this->threads.resize( + nThreads); // safe to delete because the threads are detached + this->flags.resize( +@@ -238,16 +244,10 @@ + if (thread->joinable()) + thread->join(); + } +- // wait for the terminated threads to finish +- for (auto& thread : this->terminating_threads) { +- if (thread->joinable()) +- thread->join(); +- } + // if there were no threads in the pool but some functors in the queue, the functors are not deleted by the threads + // therefore delete them here + this->clear_queue(); + this->threads.clear(); +- this->terminating_threads.clear(); + this->flags.clear(); + } + +@@ -349,7 +349,6 @@ + } + + std::vector> threads; +- std::vector> terminating_threads; + std::vector>> flags; + mutable pvt::ThreadsafeQueue*> q; + std::atomic isDone;