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.

Bug Report: 2017.2.0 Unity integration: exception in AutoObject Finalizer

0 votes
In Unity integration v2017.2 6500 contain some logically invalid code that causes runtime/compile-time exceptions:

Unhandled Exception: System.InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
  at (wrapper managed-to-native) UnityEngine.Object:EnsureRunningOnMainThread ()
  at UnityEngine.Object.GetInstanceID () [0x00002] in /build/Runtime/Export/UnityEngineObject.cs:31
  at UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) [0x0003b] in /build/Runtime/Export/UnityEngineObject.cs:134
  at UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) [0x00025] in /build/Runtime/Export/UnityEngineObject.cs:98
  at UnityEngine.Object.op_Equality (UnityEngine.Object x, UnityEngine.Object y) [0x00003] in /build/Runtime/Export/UnityEngineObject.cs:253
  at AkSoundEngine.InternalGameObjectHash (UnityEngine.GameObject gameObject) [0x00003] in /Client/Assets/Wwise/Deployment/API/Handwritten/AkSoundEngine.cs:62
  at AkSoundEngine.GetAkGameObjectID (UnityEngine.GameObject gameObject) [0x00007] in /Client/Assets/Wwise/Deployment/API/Handwritten/AkSoundEngine.cs:75
  at AkSoundEngine.UnregisterGameObj (UnityEngine.GameObject gameObject) [0x00002] in /Client/Assets/Wwise/Deployment/API/Handwritten/AkSoundEngine.cs:98
  at AkSoundEngine+AutoObject.Finalize () [0x00007] in /Client/Assets/Wwise/Extensions/AkSoundEngine.extensions.cs:23

As you can find this happens because AutoObject attempt to call native methods from GarbageCollection thread, which is not supported by Unity.
Exceptions doesn't show up in unity console (due to GC thread?), but could be seen in log files, or can be catched with try-catch statement in finalizer

We have not investigated all consequences of such behavior, but the most obvious is that resource cleaning doesn't actually happen as designed.
asked Feb 8, 2018 in General Discussion by Maksym H. (110 points)
We have the same thing. Only happens in Editor play mode when changing scenes. We are using Unity 2018.3.0f2 with Wwise integration 2018.1.5.6835.1288

InvalidOperationException: EnsureRunningOnMainThread can only be called from the main thread
UnityEngine.Object.EnsureRunningOnMainThread () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:153)
UnityEngine.Object.GetInstanceID () (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:73)
UnityEngine.Object.IsNativeObjectAlive (UnityEngine.Object o) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:182)
UnityEngine.Object.CompareBaseObjects (UnityEngine.Object lhs, UnityEngine.Object rhs) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:140)
UnityEngine.Object.op_Equality (UnityEngine.Object x, UnityEngine.Object y) (at C:/buildslave/unity/build/Runtime/Export/UnityEngineObject.bindings.cs:403)
AkSoundEngine.InternalGameObjectHash (UnityEngine.GameObject gameObject) (at Assets/Plugins/Wwise/Deployment/API/Handwritten/Common/AkSoundEngine.cs:76)
AkSoundEngine.GetAkGameObjectID (UnityEngine.GameObject gameObject) (at Assets/Plugins/Wwise/Deployment/API/Handwritten/Common/AkSoundEngine.cs:95)
AkSoundEngine.UnregisterGameObj (UnityEngine.GameObject gameObject) (at Assets/Plugins/Wwise/Deployment/API/Handwritten/Common/AkSoundEngine.cs:136)
AkSoundEngine+AutoObject.Finalize () (at Assets/Plugins/Wwise/Extensions/AkSoundEngine.extensions.cs:24)
UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)

1 Answer

0 votes
hello, have you fix this? We have this issue too.
answered 5 days ago by Jianyong L. (140 points)
...