Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Bugfix/unr-1453 fix net dormancy #1364

Merged
merged 49 commits into from
Oct 2, 2019
Merged

Bugfix/unr-1453 fix net dormancy #1364

merged 49 commits into from
Oct 2, 2019

Conversation

m-samiec
Copy link
Collaborator

@m-samiec m-samiec commented Sep 24, 2019

Description

Actors can now go dormant within Spatial and their actors will be cleaned up.

Requires engine PR - https://github.com/improbableio/UnrealEngine/pull/258

Release note

Feature:

Tests

Tested locally within a gym, will upload to TPS.

Primary reviewers

@improbable-valentyn @samiwh

@improbable-prow-robot improbable-prow-robot added jira/no-ticket Indicates a PR has no corresponding JIRA ticket size/L Denotes a PR that changes 150-299 lines, ignoring generated files. and removed WIP-do-not-merge labels Sep 24, 2019
@@ -1496,6 +1518,35 @@ bool USpatialNetDriver::CreateSpatialNetConnection(const FURL& InUrl, const FUni
return true;
}

void USpatialNetDriver::ProcessPendingDormancy()
{
TArray<TWeakObjectPtr<USpatialActorChannel>> RemoveChannels;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build a set of channels that are still pending, as per offline discussion.

@@ -1027,6 +1046,7 @@ void USpatialNetDriver::ServerReplicateActors_ProcessPrioritizedActors(UNetConne
}

Channel = GetOrCreateSpatialActorChannel(Actor);
check(Channel == nullptr || Channel->Actor != nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reevaluate this check.

@@ -1692,6 +1743,7 @@ void USpatialPendingNetGame::SendJoin()

void USpatialNetDriver::AddActorChannel(Worker_EntityId EntityId, USpatialActorChannel* Channel)
{
check(Channel != nullptr && Channel->Actor != nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reevaluate this check.

@@ -1715,6 +1767,7 @@ USpatialActorChannel* USpatialNetDriver::GetOrCreateSpatialActorChannel(UObject*
{
check(TargetObject);
USpatialActorChannel* Channel = GetActorChannelByEntityId(PackageMap->GetEntityIdFromObject(TargetObject));
check(Channel == nullptr || Channel->Actor != nullptr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reevaluate this check.

@m-samiec m-samiec changed the title Bugfix/fix net dormancy Bugfix/unr-1453 fix net dormancy Oct 1, 2019
@@ -358,7 +380,10 @@ void USpatialReceiver::HandleActorAuthority(const Worker_AuthorityChangeOp& Op)
}
}

UpdateShadowData(Op.entity_id);
if (bDormantActor == false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (bDormantActor == false)
if (!bDormantActor)

Copy link
Contributor

@improbable-valy improbable-valy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the logic for when a dormant actor gets destroyed on the server - potentially adjust NotifyActorDestroyed.

@@ -41,6 +41,8 @@ class SPATIALGDK_API USpatialNetConnection : public UIpConnection
///////
// End NetConnection Interface

virtual bool IsReplayConnection() const override { return false; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this also in the NetConnection interface?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Smart

if (IsDormantEntity(EntityId) && ThisActor->HasAuthority())
{
// Deliberately don't unregister the dormant entity, but let it get cleaned up in the entity remove op process
check(StaticComponentView->GetAuthority(EntityId, SpatialGDK::Position::ComponentId) == WORKER_AUTHORITY_AUTHORITATIVE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a crash if the last update we sent before making the actor dormant caused it to cross a boundary.

Channel->ConditionalCleanUp(false, EChannelCloseReason::Dormancy);
}
}
PendingDormantChannels = std::move(RemainingChannels);
Copy link
Contributor

@improbable-valy improbable-valy Oct 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit

Suggested change
PendingDormantChannels = std::move(RemainingChannels);
PendingDormantChannels = MoveTemp(RemainingChannels);

if (Channel != nullptr && Channel->Actor == nullptr)
{
// This shouldn't occur, but can often crop up whilst we are refactoring entity/actor/channel lifecycles.
UE_LOG(LogSpatialOSNetDriver, Error, TEXT("Failed to correct initialize SpatialActorChannel for [%s]"), *TargetObject->GetName());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UE_LOG(LogSpatialOSNetDriver, Error, TEXT("Failed to correct initialize SpatialActorChannel for [%s]"), *TargetObject->GetName());
UE_LOG(LogSpatialOSNetDriver, Error, TEXT("Failed to correctly initialize SpatialActorChannel for [%s]"), *TargetObject->GetName());

ci/unreal-engine.version Outdated Show resolved Hide resolved
@m-samiec m-samiec merged commit 03b0fdc into master Oct 2, 2019
@m-samiec m-samiec deleted the bugfix/fix-net-dormancy branch October 2, 2019 13:25
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
jira/no-ticket Indicates a PR has no corresponding JIRA ticket size/XL Denotes a PR that changes 300-599 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants