AIPerceptionSystem crashes on update listener

Hi,
The crash occurs once you call RequestStimuliListenerUpdate on UAIPerceptionComponent that doesn’t use all registered senses.

Reproduction steps:

  1. Create an Actor with UAIPerceptionComponent and assign Sight AND Hearing sense to it.
  2. Create another such Actor, but this time assign only one sense Sight or Hearing.
  3. At random time in game call RequestStimuliListenerUpdate on the second actor.
  4. Viola, the game crashes.

The problem is with the following code that exists in both senses in function OnListenerUpdateImpl(const FPerceptionListener& UpdatedListener)

const FPerceptionListenerID ListenerID = UpdatedListener.GetListenerID();
	
if (UpdatedListener.HasSense(GetSenseID()))
{
	const UAISenseConfig_Hearing* SenseConfig = Cast<const UAISenseConfig_Hearing>(UpdatedListener.Listener->GetSenseConfig(GetSenseID()));
	check(SenseConfig);
	FDigestedHearingProperties& PropertiesDigest = DigestedProperties.FindOrAdd(ListenerID);
	PropertiesDigest = FDigestedHearingProperties(*SenseConfig);
}
else
{
	DigestedProperties.FindAndRemoveChecked(ListenerID);
}

As you can see once the UpdatedListener.HasSense(GetSenseID()) fails it forces a checked removal (FindAndRemoveChecked) of a ListenerID that actually never existed for this sense, what eventually asserts on check(PairId.IsValidId());

I hope I helped with identifying the problem and that it’s gonna be fixed soon. Thank’s in advance.
Cheers,

Hey -

I was able to reproduce the crash you mentioned and have submitted a bug report (UE-21233) for investigation.

Cheers