-
Notifications
You must be signed in to change notification settings - Fork 142
Conversation
@@ -1496,6 +1518,35 @@ bool USpatialNetDriver::CreateSpatialNetConnection(const FURL& InUrl, const FUni | |||
return true; | |||
} | |||
|
|||
void USpatialNetDriver::ProcessPendingDormancy() | |||
{ | |||
TArray<TWeakObjectPtr<USpatialActorChannel>> RemoveChannels; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reevaluate this check.
@@ -358,7 +380,10 @@ void USpatialReceiver::HandleActorAuthority(const Worker_AuthorityChangeOp& Op) | |||
} | |||
} | |||
|
|||
UpdateShadowData(Op.entity_id); | |||
if (bDormantActor == false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (bDormantActor == false) | |
if (!bDormantActor) |
There was a problem hiding this 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
.
SpatialGDK/Source/SpatialGDK/Public/EngineClasses/SpatialActorChannel.h
Outdated
Show resolved
Hide resolved
SpatialGDK/Source/SpatialGDK/Public/EngineClasses/SpatialActorChannel.h
Outdated
Show resolved
Hide resolved
@@ -41,6 +41,8 @@ class SPATIALGDK_API USpatialNetConnection : public UIpConnection | |||
/////// | |||
// End NetConnection Interface | |||
|
|||
virtual bool IsReplayConnection() const override { return false; } |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Smart
Co-Authored-By: improbable-valentyn <32096431+improbable-valentyn@users.noreply.github.com>
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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()); |
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