From 950289db9f93af31525a2cfb62cb60f47785b99f Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 3 Dec 2022 11:23:26 +0100 Subject: [PATCH] Fix crash when drawing scene in async and content streaming updates model residency --- Source/Engine/Level/Scene/SceneRendering.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Source/Engine/Level/Scene/SceneRendering.cpp b/Source/Engine/Level/Scene/SceneRendering.cpp index 07990cb79..55d3946e3 100644 --- a/Source/Engine/Level/Scene/SceneRendering.cpp +++ b/Source/Engine/Level/Scene/SceneRendering.cpp @@ -42,9 +42,21 @@ FORCE_INLINE bool FrustumsListCull(const BoundingSphere& bounds, const ArrayScenes.Add(this); + + // Add additional lock during scene rendering (prevents any Actors cache modifications on content streaming threads - eg. when model residency changes) + Locker.Lock(); + } + else if (category == PostRender) + { + // Release additional lock + Locker.Unlock(); + } auto& view = renderContextBatch.GetMainContext().View; - for (auto& renderContext : renderContextBatch.Contexts) - renderContext.List->Scenes.Add(this); auto& list = Actors[(int32)category]; _drawListData = list.Get(); _drawListSize = list.Count();