fix some performance issues

This commit is contained in:
rootdarkarchon
2023-01-05 17:57:30 +01:00
parent 7e87dc61e7
commit 90a25c23dc
5 changed files with 25 additions and 9 deletions

View File

@@ -9,6 +9,7 @@ using System.Collections.Concurrent;
using System.Text;
using Penumbra.Api.Enums;
using Penumbra.Api.Helpers;
using System.Threading.Tasks;
namespace MareSynchronos.Managers;
@@ -126,10 +127,13 @@ public class IpcManager : IDisposable
private void ResourceLoaded(IntPtr ptr, string arg1, string arg2)
{
if (ptr != IntPtr.Zero && string.Compare(arg1, arg2, true, System.Globalization.CultureInfo.InvariantCulture) != 0)
Task.Run(() =>
{
PenumbraResourceLoadEvent?.Invoke(ptr, arg1, arg2);
}
if (ptr != IntPtr.Zero && string.Compare(arg1, arg2, true, System.Globalization.CultureInfo.InvariantCulture) != 0)
{
PenumbraResourceLoadEvent?.Invoke(ptr, arg1, arg2);
}
});
}
private void HandleActionQueue()

View File

@@ -179,13 +179,15 @@ public class PlayerManager : IDisposable
token.ThrowIfCancellationRequested();
}
while (!PermanentDataCache.IsReady && !token.IsCancellationRequested)
int timeOut = 10000;
while (!PermanentDataCache.IsReady && !token.IsCancellationRequested && timeOut >= 0)
{
Logger.Verbose("Waiting until cache is ready");
Logger.Verbose("Waiting until cache is ready (Timeout: " + TimeSpan.FromMilliseconds(timeOut) + ")");
await Task.Delay(50, token).ConfigureAwait(false);
timeOut -= 50;
}
if (token.IsCancellationRequested) return null;
if (token.IsCancellationRequested || timeOut <= 0) return null;
Logger.Verbose("Cache creation complete");

View File

@@ -155,6 +155,7 @@ public class TransientResourceManager : IDisposable
filePath = filePath.ToLowerInvariant().Replace("\\", "/", StringComparison.OrdinalIgnoreCase);
var replacedGamePath = gamePath.ToLowerInvariant().Replace("\\", "/", StringComparison.OrdinalIgnoreCase);
if (string.Equals(filePath, replacedGamePath, StringComparison.OrdinalIgnoreCase)) return;
if (TransientResources[gameObject].Contains(replacedGamePath) ||
SemiTransientResources.Any(r => r.Value.Any(f =>

View File

@@ -3,7 +3,7 @@
<PropertyGroup>
<Authors></Authors>
<Company></Company>
<Version>0.5.23</Version>
<Version>0.5.24</Version>
<Description></Description>
<Copyright></Copyright>
<PackageProjectUrl>https://github.com/Penumbra-Sync/client</PackageProjectUrl>

View File

@@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
using MareSynchronos.FileCache;
using MareSynchronos.Managers;
using MareSynchronos.Utils;
using System;
namespace MareSynchronos.Models;
@@ -40,8 +41,16 @@ public class FileReplacement
_ = Task.Run(() =>
{
var cache = fileDbManager.GetFileCacheByPath(ResolvedPath)!;
Hash = cache.Hash;
try
{
var cache = fileDbManager.GetFileCacheByPath(ResolvedPath)!;
Hash = cache.Hash;
}
catch (Exception ex)
{
Logger.Warn("Could not set Hash for " + ResolvedPath + ", resetting to original");
ResolvedPath = GamePaths.First();
}
});
}