Community Q&A

Where Wwise users help each other out!

Audiokinetic's Community Q&A is the forum where Wwise users ask and answer questions within the Wwise community. Contact Sales if your project requires a support plan.

Unity play-in-editor Wwise crash on hitting stop button, in AkTerminator

+4 votes
We're getting a Unity editor crash fairly consistently when playing in editor, right when we hit Stop. Some users get it every third time they stop or so, others get it much less frequently.

Wwise version is v2016.1.3 Build 5878.

It's happened on the last few Unity point releases, currently on Unity 5.4.3f1.

One thing that seemed relevant was that the Script Execution Order for AkTerminator needs to be fairly late. For some reason mine wasn't set properly, so I changed it to 31000. That seemed to reduce the crashes at least on my machine, but other users still report plenty of crashes.

We were calling AkSoundEngine.SetRTPCValue() three times per frame to set our volume levels, which most of the time weren't changing. Now I only make that call when they change. Again, it seemed to help the crashes, but it's really hard to tell. (Looking at what AkTerminator does to try to wait for things to settle down before terminating Wwise, it seemed like spamming events or RTPCs or whatever might exacerbate the issue, but that's purely a guess.)

This issue is costing us a lot of productivity right now because our project is large enough that it takes a while when you first hit play after starting Unity, so a crash wastes probably 5+ minutes each time. Any help is really appreciated!

The stack trace at the bottom of Editor.log usually looks like this:

========== OUTPUTING STACK TRACE ==================

0x00007FFADB2743B7 (AkSoundEngine) AK::MemoryMgr::Term
0x00007FFADB274784 (AkSoundEngine) AK::MemoryMgr::Term
0x00007FFADB2736A9 (AkSoundEngine) AK::MemoryMgr::Free
0x00007FFADB1A6C83 (AkSoundEngine) AK::SoundEngine::Term
  ERROR: SymGetSymFromAddr64, GetLastError: 'Attempt to access invalid address.' (Address: 00007FFADB194849)
0x00007FFADB194849 (AkSoundEngine)
0x00000000261E346D (Mono JIT Code) (wrapper managed-to-native) AkSoundEnginePINVOKE:CSharp_Term ()
0x00000000261E3345 (Mono JIT Code) [C:\_airship\BattleChasers\Source\Assets\Wwise\Deployment\API\Generated\Windows\AkSoundEngine_Windows.cs:2360] AkSoundEngine:Term ()
0x00000000261E1D55 (Mono JIT Code) [C:\_airship\BattleChasers\Source\Assets\Wwise\Deployment\Components\AkTerminator.cs:93] AkTerminator:Terminate ()
0x00000000261E178D (Mono JIT Code) [C:\_airship\BattleChasers\Source\Assets\Wwise\Deployment\Components\AkTerminator.cs:43] AkTerminator:OnApplicationQuit ()
0x0000000005F07012 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007FFAAD8D539F (mono) [c:\buildslave\mono\build\mono\mini\mini.c:4937] mono_jit_runtime_invoke
0x00007FFAAD828385 (mono) [c:\buildslave\mono\build\mono\metadata\object.c:2623] mono_runtime_invoke
0x0000000140362C9F (Unity) scripting_method_invoke
0x00000001404C99BF (Unity) ScriptingInvocation::Invoke
0x0000000140344146 (Unity) MonoBehaviour::HandleNotifications
0x000000014004AAE2 (Unity) MessageHandler::HandleMessage
0x000000014004B1B4 (Unity) GameObject::SendMessageAny
0x00000001403D2959 (Unity) SendMessageToEveryone
0x00000001404665C4 (Unity) NotifyPlayerQuit
0x0000000140BE2811 (Unity) Application::ExitPlayMode
0x0000000140BE2C3B (Unity) Application::SetIsPlaying
0x0000000140BE3716 (Unity) Application::TickTimer
0x0000000140E47E2E (Unity) FindMonoBinaryToUse
0x0000000140E49461 (Unity) WinMain
0x00000001415AD460 (Unity) strnlen
0x00007FFAE9E88364 (KERNEL32) BaseThreadInitThunk

========== END OF STACKTRACE ===========
asked Dec 21, 2016 in General Discussion by Christopher B. (140 points)

1 Answer

0 votes
Same issue here, again and again! Maybe an audiokinetic member can answer and give more informations ?
answered Aug 7, 2017 by Olivier F. (230 points)
Ok, I found a fix for this crash!

Add this in AKTerminator.cs:

    void OnEnable()
        //The sound engine was not terminated normally.  Make this instance the one that will manage termination.
        //This happen when Unity resets everything when a script changes.
        if (ms_Instance == null && AkSoundEngine.IsInitialized())
            ms_Instance = this;