Skip to content
This repository has been archived by the owner on Jan 18, 2022. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/fix snapshot reloading crash (#979)
Browse files Browse the repository at this point in the history
* The original code asserts when reloading a snapshot because it makes an assumption that the worker stats will be present.  This change removes the assumption.

* update CHANGELOG.md
cmsmithio authored Jun 3, 2019
1 parent 3fbe6ac commit 03fa34a
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Singletons authority and state resumes correct when reconnecting servers to snapshot.
- Fixed a crash when retrying reliable RPCs with UObject arguments that got destroyed before the RPC was retried.
- Fixed path naming issues in setup.sh
- Fixed assert/crash in SpatialMetricsDisplay that occurred when reloading a snapshot.

### External contributors:

Original file line number Diff line number Diff line change
@@ -182,16 +182,15 @@ void ASpatialMetricsDisplay::Tick(float DeltaSeconds)

for (const FWorkerStats& OneWorkerStats : WorkerStats)
{
const float TimeSinceUpdate = CurrentTime - WorkerStatsLastUpdateTime[OneWorkerStats.WorkerName];

if (TimeSinceUpdate > DropStatsIfNoUpdateForTime)
if (ShouldRemoveStats(SpatialNetDriver->Time, OneWorkerStats))
{
WorkerStatsToRemove.Add(OneWorkerStats);
}
}

for (const FWorkerStats& OneWorkerStats : WorkerStatsToRemove)
{
WorkerStatsLastUpdateTime.Remove(OneWorkerStats.WorkerName);
WorkerStats.Remove(OneWorkerStats);
}
}
@@ -234,3 +233,16 @@ void ASpatialMetricsDisplay::Tick(float DeltaSeconds)

ServerUpdateWorkerStats(SpatialNetDriver->Time, Stats);
}

bool ASpatialMetricsDisplay::ShouldRemoveStats(const float CurrentTime, const FWorkerStats& OneWorkerStats) const
{
const float* LastUpdateTime = WorkerStatsLastUpdateTime.Find(OneWorkerStats.WorkerName);

if (LastUpdateTime == nullptr)
{
return true;
}

const float TimeSinceUpdate = CurrentTime - *LastUpdateTime;
return TimeSinceUpdate > DropStatsIfNoUpdateForTime;
}
Original file line number Diff line number Diff line change
@@ -59,6 +59,7 @@ class SPATIALGDK_API ASpatialMetricsDisplay :
UFUNCTION(CrossServer, Unreliable, WithValidation)
virtual void ServerUpdateWorkerStats(const float Time, const FWorkerStats& OneWorkerStats);

bool ShouldRemoveStats(const float CurrentTime, const FWorkerStats& OneWorkerStats) const;
void DrawDebug(class UCanvas* Canvas, APlayerController* Controller);

struct MovementCorrectionRecord

0 comments on commit 03fa34a

Please sign in to comment.