From f0873411df91e28d34ddb77e522f8ab691eece3c Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 6 Mar 2026 11:10:13 +0100 Subject: [PATCH] Minor fix for Web no threads --- Source/Engine/Content/Storage/FlaxChunk.h | 1 + Source/Engine/Content/Storage/FlaxStorage.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/Source/Engine/Content/Storage/FlaxChunk.h b/Source/Engine/Content/Storage/FlaxChunk.h index 1d3bdce1a..4b33e47a2 100644 --- a/Source/Engine/Content/Storage/FlaxChunk.h +++ b/Source/Engine/Content/Storage/FlaxChunk.h @@ -91,6 +91,7 @@ public: /// Flag set to indicate that chunk is during loading (atomic access to sync multiple reading threads). /// int64 IsLoading = 0; + /// /// The chunk data. /// diff --git a/Source/Engine/Content/Storage/FlaxStorage.cpp b/Source/Engine/Content/Storage/FlaxStorage.cpp index 362257369..2fb670e94 100644 --- a/Source/Engine/Content/Storage/FlaxStorage.cpp +++ b/Source/Engine/Content/Storage/FlaxStorage.cpp @@ -714,10 +714,12 @@ bool FlaxStorage::LoadAssetChunk(FlaxChunk* chunk) ASSERT(IsLoaded()); ASSERT(chunk != nullptr && _chunks.Contains(chunk)); +#if PLATFORM_THREADS_LIMIT > 1 // Protect against loading the same chunk from multiple threads at once while (Platform::InterlockedCompareExchange(&chunk->IsLoading, 1, 0) != 0) Platform::Sleep(1); SCOPE_EXIT{ Platform::AtomicStore(&chunk->IsLoading, 0); }; +#endif if (chunk->IsLoaded()) return false;