From 8dc4f794b3d03527907b27c8c46d9c33cb132ea3 Mon Sep 17 00:00:00 2001 From: Kevin Trogant Date: Wed, 28 Feb 2024 13:57:50 +0100 Subject: [PATCH] Workaround for memory corruption in asset processor Somehow the asset processor threads corrupt each others memory - replace the asset of thread X with the asset of thread Y. Weird. --- src/asset_compiler/asset_compiler.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/asset_compiler/asset_compiler.c b/src/asset_compiler/asset_compiler.c index 13381c6..9d2d54f 100644 --- a/src/asset_compiler/asset_compiler.c +++ b/src/asset_compiler/asset_compiler.c @@ -49,7 +49,7 @@ typedef struct { RT_CVAR_S(rt_AssetDirectory, "Name of the asset directory. Default: assets", "assets"); RT_CVAR_I(rt_AssetDBSize, "Size of the asset database. Default: 1024", 1024); -RT_CVAR_I(rt_AssetProcessingThreads, "Number of asset processing threads. Default: 4", 4); +RT_CVAR_I(rt_AssetProcessingThreads, "Number of asset processing threads. Default: 4", 1); RT_CVAR_I(rt_AssetProcessorArenaSize, "Size of the per-thread asset processor arena. Default: 128 MiB", (int)RT_MB(128)); @@ -394,9 +394,8 @@ static void ProcessorThreadEntry(void *param) { } RT_DLLEXPORT void rtWaitForAssetProcessing(void) { - int turns = 5; + int turns = 10; while (turns > 0) { - rtSleep(100); int in_processing_count = 0; for (int i = 0; i < rt_AssetDBSize.i; ++i) { rtLockRead(&_asset_db.lock); @@ -404,8 +403,10 @@ RT_DLLEXPORT void rtWaitForAssetProcessing(void) { ++in_processing_count; rtUnlockRead(&_asset_db.lock); } - if (!in_processing_count) + if (!in_processing_count) { --turns; + rtSleep(250); + } } }