-
Notifications
You must be signed in to change notification settings - Fork 885
Observer.cs: Error callstack not helpful #247
Description
We are using UniRX in combination with Unity for some years now and are REALLY happy with it.
During the last 2 months we are getting strange errors though, which are really hard to fix, as the callstack is not very helpful.
For example there might be a null reference error somewhere. But the console does not tell us where, but always points to Observer.cs.
Or there might be an IEnumeration that is being changed during a foreach loop of that same IEnumarion. Again, we don't know where this happens, as we are only pointed to Observer.cs.
Fixing bugs became really tedious and a lot of guessing work.
We then thought that maybe something is wrong with our thread management, so we removed that and put everything back on the main thread for testing. Still, same error. We then removed all MicroCoroutines. Same error.
Here is the callstack for a random error so you can see what the problem is:
NullReferenceException: Object reference not set to an instance of an object
UniRx.Stubs.<Throw>m__1 (System.Exception ex) (at Assets/GameFramework/Modules/UniRx/Scripts/Observer.cs:495)
UniRx.Observer+Subscribe`1[T].OnError (System.Exception error) (at Assets/GameFramework/Modules/UniRx/Scripts/Observer.cs:172)
UniRx.Operators.FromMicroCoroutineObservable`1+FromMicroCoroutine[T].OnError (System.Exception error) (at Assets/GameFramework/Modules/UniRx/Scripts/UnityEngineBridge/Operators/FromCoroutine.cs:130)
UniRx.ObserveExtensions+<PublishUnityObjectValueChanged>c__Iterator2`2[TSource,TProperty].MoveNext () (at Assets/GameFramework/Modules/UniRx/Scripts/UnityEngineBridge/ObserveExtensions.cs:233)
UniRx.InternalUtil.MicroCoroutine.Run () (at Assets/GameFramework/Modules/UniRx/Scripts/InternalUtil/MicroCoroutine.cs:70)
UnityEngine.Debug:LogException(Exception)
UniRx.MainThreadDispatcher:<unhandledExceptionCallback>m__3(Exception) (at Assets/GameFramework/Modules/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs:389)
UniRx.MainThreadDispatcher:<Awake>m__0(Exception) (at Assets/GameFramework/Modules/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs:492)
UniRx.InternalUtil.MicroCoroutine:Run() (at Assets/GameFramework/Modules/UniRx/Scripts/InternalUtil/MicroCoroutine.cs:92)
UniRx.<RunUpdateMicroCoroutine>c__Iterator0:MoveNext() (at Assets/GameFramework/Modules/UniRx/Scripts/UnityEngineBridge/MainThreadDispatcher.cs:530)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
The "NullReferenceException: Object reference not set to an instance of an object" really is only an example here. This could be anything.
The error always begins with Observer.cs and ends in MainThreadDispatcher.cs. There is never any traceable route to an error in our code. But in the end it always is an error in our code and each time we have to guess were it comes from.
We are on Unity 2017.1.1p1 with NET 4.6 and use the latest version of UniRx.
Any ideas what is going on here?