# AIPerceptionSystem crashes on update listener

**URL:** <https://forums.unrealengine.com/t/aiperceptionsystem-crashes-on-update-listener/332636>\
**Category:** AI\
**Tags:** Perception, unreal-engine, crash, question\
**Created:** [September 18, 2015, 10:54am UTC](https://forums.unrealengine.com/t/aiperceptionsystem-crashes-on-update-listener/332636 "2015-09-18T10:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_eed5b8341](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_eed5b8341](https://forums.unrealengine.com/u/anonymous_user_eed5b8341)\
**Post date:** [September 18, 2015, 10:54am UTC](https://forums.unrealengine.com/t/aiperceptionsystem-crashes-on-update-listener/332636/1 "2015-09-18T10:54:38Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [September 18, 2015, 2:25pm UTC](https://forums.unrealengine.com/t/aiperceptionsystem-crashes-on-update-listener/332636/2 "2015-09-18T14:25:53Z")

</div>

Hey -

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

Cheers
