aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJumpman <41526355+JumpmanSr@users.noreply.github.com>2022-03-14 22:49:35 -0400
committerGitHub <noreply@github.com>2022-03-15 03:49:35 +0100
commit73feac5819903bbc16ebb3b4a47b5734d5699492 (patch)
tree3602a1dea8895c5fc8f340bb5aeafd8fdd6ab0a7
parente5ad1dfa48590685fd93443a2adfd8568f6c1db0 (diff)
Caching local network info and using an event handler to invalidate as needed (improves menu slow down issue in FE3H) (#2761)1.1.75
* Update IGeneralService.cs Fix IPV4 local ip related frame drop in fire emblem by rewriting [CommandHipc(12)] * Fix IPV4 Local IP Slowdown & Style Fixes fix a missing space * Remove unnecessary line * Fix for hardcoding which index to use * Replace argument with empty string. By sending an empty string to Dns.GetHostAddresses("") you get back localhost info only. * Add caching, undo change in GetCurrentIpAddress Implement caching and revert the GetCurrentIP() function, speed improvements still present. * Remove unnecessary using * Syntax fixes and removing extra lines Requested changes by AcK77 * Properly unsubscribe from event handler Adds an unsubscribe in the dispose section of IGeneralService
-rw-r--r--Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
index 2296838e..ba91f08c 100644
--- a/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
+++ b/Ryujinx.HLE/HOS/Services/Nifm/StaticService/IGeneralService.cs
@@ -14,6 +14,9 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
{
private GeneralServiceDetail _generalServiceDetail;
+ private IPInterfaceProperties _targetPropertiesCache = null;
+ private UnicastIPAddressInformation _targetAddressInfoCache = null;
+
public IGeneralService()
{
_generalServiceDetail = new GeneralServiceDetail
@@ -22,6 +25,8 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
IsAnyInternetRequestAccepted = true // NOTE: Why not accept any internet request?
};
+ NetworkChange.NetworkAddressChanged += new NetworkAddressChangedEventHandler(LocalInterfaceCacheHandler);
+
GeneralServiceManager.Add(_generalServiceDetail);
}
@@ -165,6 +170,11 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
return (null, null);
}
+ if (_targetPropertiesCache != null && _targetAddressInfoCache != null)
+ {
+ return (_targetPropertiesCache, _targetAddressInfoCache);
+ }
+
IPInterfaceProperties targetProperties = null;
UnicastIPAddressInformation targetAddressInfo = null;
@@ -194,13 +204,26 @@ namespace Ryujinx.HLE.HOS.Services.Nifm.StaticService
}
}
+ _targetPropertiesCache = targetProperties;
+ _targetAddressInfoCache = targetAddressInfo;
+
return (targetProperties, targetAddressInfo);
}
+ private void LocalInterfaceCacheHandler(object sender, EventArgs e)
+ {
+ Logger.Info?.Print(LogClass.ServiceNifm, $"NetworkAddress changed, invalidating cached data.");
+
+ _targetPropertiesCache = null;
+ _targetAddressInfoCache = null;
+ }
+
protected override void Dispose(bool isDisposing)
{
if (isDisposing)
{
+ NetworkChange.NetworkAddressChanged -= LocalInterfaceCacheHandler;
+
GeneralServiceManager.Remove(_generalServiceDetail.ClientId);
}
}