Crash when calling AddToTeam after disabling perception_trigger_device

Reference ID

315ab0df-453d-e88e-616f-d89b5530d70f

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Stability

Summary

Server crashes when calling AddToTeam on a player after disabling perception_trigger_device from AgentLooksAtDeviceEvent event handler.

Steps to Reproduce

  1. Add the following to a map:
  • Perception Trigger
  • Button
  • Test Device (see code below)
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }

test_device := class(creative_device):
    @editable PerceptionTrigger: perception_trigger_device = perception_trigger_device {}
    @editable ChangeTeamButton: button_device = button_device {}

    OnBegin<override>():void=
        PerceptionTrigger.AgentLooksAtDeviceEvent.Subscribe(OnLookedAtTrigger)
        ChangeTeamButton.InteractedWithEvent.Subscribe(OnChangeTeamButton)

    OnLookedAtTrigger(Agent: agent):void=
        Print("Disabling perception_trigger_device")
        PerceptionTrigger.Disable()

    OnChangeTeamButton(Agent: agent):void=
        Print("Adding player to team")
        TeamCollection := GetPlayspace().GetTeamCollection()        
        if (TeamCollection.AddToTeam[Agent, TeamCollection.GetTeams()[2]]):
            Print("Added player to team 2")
  1. Link device to Button and Perception Trigger
  2. Start game session
  3. Look at Perception Trigger device, until you see “Disabling perception_trigger_device” in the logs
  4. Press the button

Expected Result

Player is added to Team 2

Observed Result

Player freezes in place, then gets a “Network connection lost” message.
Editor logs report an error:

[2023.09.18-19.34.58:606][604]LogNet: Warning: UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 30.01, Real: 30.01, Good: 30.01, DriverTime: 174.41, Threshold: 30.00, [UNetConnection] RemoteAddr: 3.25.183.98:15071, Name: IpConnection_1, Driver: IpNetDriver_1 IpNetDriver_1, IsServer: NO, PC: NULL, Owner: ValkyrieBeaconClient_1, UniqueId: MCP:cfa359c8474d4e399eb4c668b125a9e6
[2023.09.18-19.34.58:606][604]LogNet: Error: UEngine::BroadcastNetworkFailure: FailureType = ConnectionTimeout, ErrorString = UNetConnection::Tick: Connection TIMED OUT. Closing connection.. Elapsed: 30.01, Real: 30.01, Good: 30.01, DriverTime: 174.41, Threshold: 30.00, [UNetConnection] RemoteAddr: 3.25.183.98:15071, Name: IpConnection_1, Driver: IpNetDriver_1 IpNetDriver_1, IsServer: NO, PC: NULL, Owner: ValkyrieBeaconClient_1, UniqueId: MCP:cfa359c8474d4e399eb4c668b125a9e6, Driver = IpNetDriver_1 IpNetDriver_1
[2023.09.18-19.34.58:606][604]LogValkyrieRequestManagerEditor: Warning: Encountered Network Error!

Platform(s)

Windows, PS5

Additional Notes

The following workaround avoids the crash:

    OnLookedAtTrigger(Agent: agent):void=
        Print("Disabling perception_trigger_device")
        spawn { DisableTriggerAsync() }

    DisableTriggerAsync()<suspends>:void=
        Sleep(0.0)
        PerceptionTrigger.Disable()