Audiokinetic's Community Q&A is the forum where users can ask and answer questions within the Wwise and Strata communities. If you would like to get an answer from Audiokinetic's Technical support team, make sure you use the Support Tickets page.

HashSet IndexOutOfRangeException when auto registering object

0 votes

We've occasionally seen issues with posting events because of an `IndexOutOfRangeException` error that occurs when AkSoundEngine.cs attempts to auto register an object and its `RegisteredGameObjects` HashSet attempts to expand its capacity.

Here is a trimmed example callstack:

IndexOutOfRangeException: Index was outside the bounds of the array.
  at System.Collections.Generic.HashSet`1[T].SetCapacity (System.Int32 newSize)
  at System.Collections.Generic.HashSet`1[T].IncreaseCapacity ()
  at System.Collections.Generic.HashSet`1[T].AddIfNotPresent (T value)
  at System.Collections.Generic.HashSet`1[T].Add (T item)
  at AkSoundEngine.PostRegisterGameObjUserHook (AKRESULT result, UnityEngine.GameObject gameObject, System.UInt64 id)
  at AkSoundEngine.RegisterGameObj (UnityEngine.GameObject gameObject, System.String name)
  at AkSoundEngine+AutoObject..ctor (UnityEngine.GameObject go)
  at AkSoundEngine.AutoRegister (UnityEngine.GameObject gameObject, System.UInt64 id)
  at AkSoundEngine.PreGameObjectAPICallUserHook (UnityEngine.GameObject gameObject, System.UInt64 id)
  at AkSoundEngine.PreGameObjectAPICall (UnityEngine.GameObject gameObject, System.UInt64 id)
  at AkSoundEngine.PostEvent (System.String in_pszEventName, UnityEngine.GameObject in_gameObjectID)
  at EventUI.StartEvent (System.Object[] initData)
  [trimmed]
  at UnityEngine.SetupCoroutine.InvokeMoveNext

This exception from a HashSet is typically seen in multi-threading scenarios, but in all instances of this error occurring for us, the callstack had been executed from the main thread. This issue also has a very low repro rate, however when it does happen, any calls to `PostEvent` fail if it must auto register an object as the above exception will get thrown.

Has this been seen before? Any help is greatly appreciated.

Unity 2021.3.7f1
Wwise 2019.2.6.7381.1867

asked Mar 20, 2023 in General Discussion by Kenneth A. (100 points)

Please sign-in or register to answer this question.

...