diff --git a/Runtime/BacktraceDatabase.cs b/Runtime/BacktraceDatabase.cs index c6f50512..ab5a7e43 100644 --- a/Runtime/BacktraceDatabase.cs +++ b/Runtime/BacktraceDatabase.cs @@ -236,7 +236,7 @@ internal void Update() } if (_breadcrumbs != null) { - _breadcrumbs.Update(); + _breadcrumbs.Update(Time.unscaledTime); } LastFrameTime = Time.unscaledTime; if (!DatabaseSettings.AutoSendMode) diff --git a/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbs.cs b/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbs.cs index 6193abee..d3dc63d3 100644 --- a/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbs.cs +++ b/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbs.cs @@ -191,9 +191,9 @@ public double BreadcrumbId() return LogManager.BreadcrumbId(); } - public void Update() + public void Update(float time) { - EventHandler.Update(); + EventHandler.Update(time); } public static bool CanStoreBreadcrumbs(UnityEngineLogLevel logLevel, BacktraceBreadcrumbType backtraceBreadcrumbsLevel) diff --git a/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbsEventHandler.cs b/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbsEventHandler.cs index 99230b11..8761e0a3 100644 --- a/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbsEventHandler.cs +++ b/Runtime/Model/Breadcrumbs/BacktraceBreadcrumbsEventHandler.cs @@ -13,6 +13,10 @@ internal sealed class BacktraceBreadcrumbsEventHandler private BacktraceBreadcrumbType _registeredLevel; private NetworkReachability _networkStatus = NetworkReachability.NotReachable; private Thread _thread; + private float _lastUpdateTime = 0; + + // time in seconds between internet availability checks + private float INTERNET_AVAILABILITY_CHECK_INTERVAL_SEC = 30; public BacktraceBreadcrumbsEventHandler(BacktraceBreadcrumbs breadcrumbs) { _thread = Thread.CurrentThread; @@ -151,8 +155,13 @@ private void LogNewNetworkStatus(NetworkReachability status) Log(string.Format("Network:{0}", status), LogType.Log, BreadcrumbLevel.System); } - internal void Update() + internal void Update(float time) { + if (time - _lastUpdateTime < INTERNET_AVAILABILITY_CHECK_INTERVAL_SEC && _lastUpdateTime != 0) + { + return; + } + _lastUpdateTime = time; if (_registeredLevel.HasFlag(BacktraceBreadcrumbType.System) && Application.internetReachability != _networkStatus) { LogNewNetworkStatus(Application.internetReachability); diff --git a/Runtime/Model/Breadcrumbs/IBacktraceBreadcrumbs.cs b/Runtime/Model/Breadcrumbs/IBacktraceBreadcrumbs.cs index 5689bbff..89845713 100644 --- a/Runtime/Model/Breadcrumbs/IBacktraceBreadcrumbs.cs +++ b/Runtime/Model/Breadcrumbs/IBacktraceBreadcrumbs.cs @@ -29,7 +29,7 @@ public interface IBacktraceBreadcrumbs string GetBreadcrumbLogPath(); double BreadcrumbId(); void UnregisterEvents(); - void Update(); + void Update(float time); string Archive(); } }