From what i have seen from the code, i think in order to access GameObjectToPackagesMap you have to lock "Instance->CriticalSection".
Also i am not confortable with checking "pPackage->uUserFlags" when "pPackage" has been deleted.
I created the post mainly to warn others of the issue.
This is the fix i am using since the first post :
auto pPackage = (IAkUserEventCallbackPackage*)in_pCallbackInfo->pCookie;
if (Instance && pPackage)
{
const auto& gameObjID = in_pCallbackInfo->gameObjID;
bool deletePackage = false;
// begin edit
bool allowHandleAction = true;
// end edit
{
FScopeLock Lock(&Instance->CriticalSection);
auto pPackageSet = Instance->GameObjectToPackagesMap.Find(gameObjID);
// begin edit
allowHandleAction = (pPackageSet != nullptr);
// end edit
if (pPackageSet && in_eType == AK_EndOfEvent)
{
Instance->RemovePackageFromSet(pPackageSet, pPackage, gameObjID);
deletePackage = true;
}
}
if (in_eType == AK_EndOfEvent)
{
if (auto* Device = FAkAudioDevice::Get())
{
Device->RemovePlayingID(((AkEventCallbackInfo*)in_pCallbackInfo)->eventID, ((AkEventCallbackInfo*)in_pCallbackInfo)->playingID);
Device->CleanPinnedObjects(((AkEventCallbackInfo*)in_pCallbackInfo)->playingID);
}
}
// begin edit
if (allowHandleAction && ((pPackage->uUserFlags & in_eType) != 0))
{
pPackage->HandleAction(in_eType, in_pCallbackInfo);
}
// end edit