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.

UE4 Plugin Crashes when swapping levels. (Fix Included)

0 votes

Since upgradiing to 2017.1.xxxx we started seeing a number of crashes in the editor (could happen in game too!) on level swap. It wasn't terribly common but I root caused it to the fact that "GetWorld" for a component in UE4 can return null when swapping levels. (I.E. the world can be in-accessible during level swap).

Apologies in advance for the formatting. I don't see support for code blocks here.

The crash would occur in this function, but that's not the best place to fix it:

template<class COMPONENT_TYPE>
void FAkAudioDevice::RemovePrioritizedComponentFromList(COMPONENT_TYPE* in_ComponentToRemove, TMap<UWorld*, COMPONENT_TYPE*>& HighestPriorityComponentMap)

 

The fix is pretty simple. Add this to FAkAudioDevice::Init

// OnWorldCleanupDelegateHandle is a new member variable I declared in FAkAudioDevice
OnWorldCleanupDelegateHandle = FWorldDelegates::OnWorldCleanup.AddLambda(
[&](UWorld* WorldBeingCleanedup, bool, bool)
{
   HighestPriorityLateReverbComponentMap.Remove(WorldBeingCleanedup);
   HighestPriorityRoomComponentMap.Remove(WorldBeingCleanedup);
}
);

and add this line to tear down

FWorldDelegates::OnWorldCleanup.Remove(OnWorldCleanupDelegateHandle); 

asked Dec 5, 2017 in Feature Requests by Brent R. (100 points)

Please sign-in or register to answer this question.

...