diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2020-05-11 11:16:29 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2020-05-14 14:54:16 +0300 |
commit | 08ac4d3d71dee9fc4ec7f878e57de59c87115280 (patch) | |
tree | 422c6c0e3bef29dff7d336efbfb435c48af20737 /source/blender/blenlib/intern | |
parent | 36d9f7e37540d211add476178972e1617c1533a2 (diff) |
Fix T76553: Blender Freezes When Playing Back Animation
In some cases blender could freeze. When threads are blocked (waiting for other tasks completion) the scheduler can let the thread perform a different task. If this task wants a write-lock for something that was read-locked in the stack a dead lock will happen.
For task pools every task is isolated. For range tasks the inner loop will be isolated. The implementation is limited as isolation in TBB uses functors which are tricky to add to a C API. We decided to start with a simple and adapt were we need to.
During testing we came to this setup as it was reliable (we weren't able to let it freeze or crash) and didn't had noticeable performance impact.
Reviewed By: Brecht van Lommel
Differential Revision: https://developer.blender.org/D7688
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/task_pool.cc | 2 | ||||
-rw-r--r-- | source/blender/blenlib/intern/task_range.cc | 12 |
2 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/blenlib/intern/task_pool.cc b/source/blender/blenlib/intern/task_pool.cc index c4d60673492..42b635afcf1 100644 --- a/source/blender/blenlib/intern/task_pool.cc +++ b/source/blender/blenlib/intern/task_pool.cc @@ -114,7 +114,7 @@ class Task { /* Execute task. */ void operator()() const { - run(pool, taskdata); + tbb::this_task_arena::isolate([this] { run(pool, taskdata); }); } }; diff --git a/source/blender/blenlib/intern/task_range.cc b/source/blender/blenlib/intern/task_range.cc index a8447c305e0..55de35f0060 100644 --- a/source/blender/blenlib/intern/task_range.cc +++ b/source/blender/blenlib/intern/task_range.cc @@ -89,11 +89,13 @@ struct RangeTask { void operator()(const tbb::blocked_range<int> &r) const { - TaskParallelTLS tls; - tls.userdata_chunk = userdata_chunk; - for (int i = r.begin(); i != r.end(); ++i) { - func(userdata, i, &tls); - } + tbb::this_task_arena::isolate([this, r] { + TaskParallelTLS tls; + tls.userdata_chunk = userdata_chunk; + for (int i = r.begin(); i != r.end(); ++i) { + func(userdata, i, &tls); + } + }); } void join(const RangeTask &other) |