FArchive& operator<<(struct FWeakObjectPtr&) crash

Hi.
i just found a crash when i tried my packaged game with multiplayer.
This is never reproduce when we play with less than 4 PC.
And even with more than 4 PC connected, it still rarely happens. And i really don’t know how to reproduce the bug or even fix it.

All we did is keep shooting raycast to another player, (our weapon will spawn a bullet projectile (AActor) to make it look nice). And while we fight each other, we jumping, running and go here and there (like normal fps game).

Suddenly, the game crashes and this is the call stack

[File:D:\Build\++UE4+Release-4.14+Compile\Sync\Engine\Source\Runtime\Core\Private\Serialization\Archive.cpp] [Line: 258] 
    FArchive does not support FWeakObjectPtr serialization. Use FArchiveUObject instead.
    
    
  FDebug::AssertFailed()
  FArchive::operator<<()
  FHitResult::NetSerialize()
  StructProperty::NetSerializeItem()
  FRepLayout::UpdateUnmappedObjects_r()
  FRepLayout::UpdateUnmappedObjects_r()
  FRepLayout::UpdateUnmappedObjects()
  FObjectReplicator::UpdateUnmappedObjects()
  UNetDriver::TickFlush()
  ?ExecuteIfSafe@?$TBaseUObjectMethodDelegateInstance@$0A@VUNetDriver@@$$A6AXM@Z$$V@@UEBA_NM@Z()
  TBaseMulticastDelegate<void,float>::Broadcast()
  UWorld::Tick()
  UGameEngine::Tick()
  FEngineLoop::Tick()
  GuardedMain()
  GuardedMainWrapper()
  WinMain()
  __scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:255]
  kernel32
  ntdll

Also, i just realized that FBitReader class is developed after 4.13.
i think maybe it has something to do with that, but im not entirely sure. Did anyone have explanation about this?

Note: i cant find any .dmp file created on my folder

Any help is appreciated. Thank you very much

This happens when you trying to replicate an Actor property inside HitResult structure. There is an engine problem that I met when writting my own bake subsystem. (Explained here) Any archives except Linker (uasset file packager) can not handle UObjects and references. This error wont pop permanently because serializers don’t serialize values that equals to the defaults. It seems your structure usually have an Actor set to null and replication not crashing. To fix this crashes you can:

  • Prevent actor properties from being not null
  • Do not replicate HitResult at all
  • Create custom replication and handle UObject replication better than engine does.

Thank you for fast reply. I actually did replicate a TArray of HitResult for clients. I will test it now, and i will let you know if the crash still happens.

Sorry for the late reply.
need to find another solution for my feature first. But yeah. 10 players, no problem right now. :slight_smile:
i’ll keep that in mind. :wink:

If you need to replicate UObjects through the network you can use RPC Calls.
For functions defined like
UFUNCTION(Reliable, Client)
void Network_AddComponentReceiver(UInteractionRecieverComponent* receiver_component, FVector CasterLocation, FName MapName);

it works fine