From 7c53b99d310d91088dc3a24beeeb18dd2958955b Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 6 May 2019 15:23:09 +0400 Subject: [PATCH 1/5] Avoid possible data race during access to the static local variable --- components/esmterrain/storage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index 1e23569b5..ec2699aa7 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -353,11 +353,11 @@ namespace ESMTerrain std::string Storage::getTextureName(UniqueTextureId id) { // Goes under used terrain blend transitions - static const std::string baseTexture = "textures\\tx_black_01.dds"; + static constexpr char baseTexture[] = "textures\\tx_black_01.dds"; if (id.first == -1) return baseTexture; - static const std::string defaultTexture = "textures\\_land_default.dds"; + static constexpr char defaultTexture[] = "textures\\_land_default.dds"; if (id.first == 0) return defaultTexture; // Not sure if the default texture really is hardcoded? From 57176ff8d40ce0dfdd23fb6f32808ea722575905 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Mon, 6 May 2019 17:07:22 +0400 Subject: [PATCH 2/5] Unload viewer and stop background jobs before resources unloading --- apps/openmw/engine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 1c95ccc93..c67aaffa4 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -257,10 +257,10 @@ OMW::Engine::~Engine() mWorkQueue = nullptr; - mResourceSystem.reset(); - mViewer = nullptr; + mResourceSystem.reset(); + delete mEncoder; mEncoder = nullptr; From ab03b9ac1cee04f91cad0e6d5618242e0067d49a Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Wed, 8 May 2019 14:42:17 +0400 Subject: [PATCH 3/5] Do not sort the Land store every savegame load - it is static anyway (bug #4844) --- CHANGELOG.md | 1 + apps/openmw/mwworld/store.cpp | 5 +++++ apps/openmw/mwworld/store.hpp | 2 ++ 3 files changed, 8 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e470c086e..e7513b553 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,6 +51,7 @@ Bug #4828: Potion looping effects VFX are not shown for NPCs Bug #4837: CTD when a mesh with NiLODNode root node with particles is loaded Bug #4841: Russian localization ignores implicit keywords + Bug #4844: Data race in savegame loading / GlobalMap render Bug #4847: Idle animation reset oddities Bug #4851: No shadows since switch to OSG Bug #4860: Actors outside of processing range visible for one frame after spawning diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index 2a0c39466..444650217 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -500,7 +500,12 @@ namespace MWWorld } void Store::setUp() { + // The land is static for given game session, there is no need to refresh it every load. + if (mBuilt) + return; + std::sort(mStatic.begin(), mStatic.end(), Compare()); + mBuilt = true; } diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 2ed81af48..c6ef401ed 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -247,6 +247,8 @@ namespace MWWorld RecordId load(ESM::ESMReader &esm); void setUp(); + private: + bool mBuilt = false; }; template <> From fae58433476824f34e51673a755fb433ddb3dfa2 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 10 May 2019 10:02:33 +0400 Subject: [PATCH 4/5] Setup the ICO settings only once instead of every loading (bug #5025) --- CHANGELOG.md | 1 + apps/openmw/mwgui/loadingscreen.cpp | 5 ----- apps/openmw/mwrender/renderingmanager.cpp | 1 + 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7513b553..310e37d16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -89,6 +89,7 @@ Bug #5001: Possible data race in the Animation::setAlpha() Bug #5004: Werewolves shield their eyes during storm Bug #5018: Spell tooltips don't support purely negative magnitudes + Bug #5025: Data race in the ICO::setMaximumNumOfObjectsToCompilePerFrame() Bug #5028: Offered price caps are not trading-specific Bug #5038: Enchanting success chance calculations are blatantly wrong Feature #1774: Handle AvoidNode diff --git a/apps/openmw/mwgui/loadingscreen.cpp b/apps/openmw/mwgui/loadingscreen.cpp index a9480f261..54382ab4d 100644 --- a/apps/openmw/mwgui/loadingscreen.cpp +++ b/apps/openmw/mwgui/loadingscreen.cpp @@ -165,11 +165,6 @@ namespace MWGui if (mMainWidget->getVisible()) return; - if (mViewer->getIncrementalCompileOperation()) - { - mViewer->getIncrementalCompileOperation()->setMaximumNumOfObjectsToCompilePerFrame(100); - } - // Assign dummy bounding sphere callback to avoid the bounding sphere of the entire scene being recomputed after each frame of loading // We are already using node masks to avoid the scene from being updated/rendered, but node masks don't work for computeBound() mViewer->getSceneData()->setComputeBoundingSphereCallback(new DontComputeBoundCallback); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 964aaa9de..0d9cbd9b0 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -268,6 +268,7 @@ namespace MWRender { mViewer->setIncrementalCompileOperation(new osgUtil::IncrementalCompileOperation); mViewer->getIncrementalCompileOperation()->setTargetFrameRate(Settings::Manager::getFloat("target framerate", "Cells")); + mViewer->getIncrementalCompileOperation()->setMaximumNumOfObjectsToCompilePerFrame(100); } mResourceSystem->getSceneManager()->setIncrementalCompileOperation(mViewer->getIncrementalCompileOperation()); From 454bae2c43d1f556fc711f3026c6f09899d9f7e4 Mon Sep 17 00:00:00 2001 From: Andrei Kortunov Date: Fri, 10 May 2019 14:22:52 +0400 Subject: [PATCH 5/5] Make PacketQueue fields atomic to avoid data races (e.g. with ParseThread) --- extern/osg-ffmpeg-videoplayer/videostate.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extern/osg-ffmpeg-videoplayer/videostate.hpp b/extern/osg-ffmpeg-videoplayer/videostate.hpp index 6abaa64cd..54519f428 100644 --- a/extern/osg-ffmpeg-videoplayer/videostate.hpp +++ b/extern/osg-ffmpeg-videoplayer/videostate.hpp @@ -80,8 +80,8 @@ struct PacketQueue { AVPacketList *first_pkt, *last_pkt; std::atomic flushing; - int nb_packets; - int size; + std::atomic nb_packets; + std::atomic size; OpenThreads::Mutex mutex; OpenThreads::Condition cond;