NodeCanvas Forums › Support › WP8 crashes and exceptions with NC2.3.7
Hello,
I’m running into some problems with NC (v2.3.7) on… Windows Phone 8, the usual whipping boy.
Problem 1 (and a solution)
————————–
First, the latest version (2.3.7) outright crashes any application due to FullSerializer. You need to change fsMetaType lines 297 to 302 from
1 2 3 4 5 6 7 8 |
#if (!UNITY_EDITOR && (UNITY_METRO)) // In WinRT/WinStore builds, Activator.CreateInstance(..., true) is broken return Activator.CreateInstance(ReflectedType); #else return Activator.CreateInstance(ReflectedType, /*nonPublic:*/ true); #endif |
to
1 2 3 |
return Activator.CreateInstance(ReflectedType); |
Otherwise, the app will crash when deserializing any scene with NodeCanvas stuff in it.
Problem 2
———
Second problem, and one I am looking for a solution is the following exception:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:DataPrograms{532A28A8-03BF-E34A-BA62-574AE031B826}InstallUnityEngine.Cloud.Analytics.DLL'. Symbols loaded. The thread 0x7f4 has exited with code 259 (0x103). 'TaskHost.exe' (CoreCLR: Silverlight AppDomain): Loaded 'C:windowssystem32en-USmscorlib.debug.resources.dll'. Module was built without symbols. A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.ni.dll A first chance exception of type 'System.Runtime.InteropServices.SEHException' occurred in UnityEngine.DLL Exception: External component has thrown an exception. Type: System.Runtime.InteropServices.SEHException Module: UnityEngine InnerException: <No Data> AdditionalInfo:<No Data> at UnityEngine.Internal.$Calli.Invoke123(Int32 arg0, Int32 arg1, Boolean arg2, Boolean arg3, Boolean arg4, Boolean arg5, Int64 arg6, IntPtr method) at UnityEngine.GameObject.GetComponentsInternal(Type type, Boolean useSearchTypeAsArrayReturnType, Boolean recursive, Boolean includeInactive, Boolean reverse, Object resultList) at UnityEngine.GameObject.GetComponents(Type type) at UnityEngine.Component.GetComponents(Type type) at NodeCanvas.Framework.GraphOwner.get_graphIsLocal() at NodeCanvas.Framework.GraphOwner.Awake() at NodeCanvas.Framework.GraphOwner.$Invoke0(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: Line: 0) SEHException: External component has thrown an exception. at UnityEngine.Internal.$Calli.Invoke123(Int32 arg0, Int32 arg1, Boolean arg2, Boolean arg3, Boolean arg4, Boolean arg5, Int64 arg6, IntPtr method) at UnityEngine.GameObject.GetComponentsInternal(Type type, Boolean useSearchTypeAsArrayReturnType, Boolean recursive, Boolean includeInactive, Boolean reverse, Object resultList) at UnityEngine.GameObject.GetComponents(Type type) at UnityEngine.Component.GetComponents(Type type) at NodeCanvas.Framework.GraphOwner.get_graphIsLocal() at NodeCanvas.Framework.GraphOwner.Awake() at NodeCanvas.Framework.GraphOwner.$Invoke0(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: <Unknown> Line: 0) |
As you can see, it crashes somewhere in GetComponents during the Awake() calls.
Best
Alain-Daniel
Hello,
Thanks for the issue reporting.
Regarding the first issue, originaly it was like you suggest, but sone people suggested the way it is now for no crashing. Hm.
Regarding the 2nd issue, can you please try and open up GraphOwner.cs and replace the ‘graphIsLocal’ property at line #48 with this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
public bool graphIsLocal{ get { if (graph == null) return false; foreach(var s in GetComponents(typeof(IScriptableComponent))){ if (s == this.graph){ return true; } } return false; } } |
If this still doesn’t work, I will provide another solution.
Thanks!
Join us on Discord: https://discord.gg/97q2Rjh
Hi Gavalakis,
For the 1st issue: I don’t know… could be different version of Unity?
2nd issue: the code didn’t work out. Still exactly the same crash. Actually, I tested just running a ‘GetComponents<Component>()’ for fun and that crashes as well…
Alain-Daniel
Hey,
Regarding 1, yeah it could be due to different Unity versions. Are you on Unity 5 by the way?
As for 2, here is another solution:
In GraphOwner.cs:
1. Replace Awake method with this code:
1 2 3 4 5 |
protected void Awake(){ graph = GetInstance(graph); } |
2. In GetInstance method line #95 replace:
instance = Graph.Clone<Graph>(originalGraph);
with :
1 2 3 4 |
instance = (Graph)ScriptableObject.CreateInstance(graphType); originalGraph.CopySerialized(instance); |
Let me know if that works for you.
Thanks
Join us on Discord: https://discord.gg/97q2Rjh
Hello again,
I hate to be the bearer of bad news, but the fix didn’t work, but I also have more information for you. Let’s do things in order however.
Issue #1: I’m on Unity 5.1.2f1. Looking at my Player Settings to spot something that may influence that behaviour, I find that the “Api Compatibility Level” is set to “.Net 2.0 Subset”. I don’t really see anything else. This is a brand new project created from scratch to test these issues, so I haven’t messed with any settings really.
Ok, now Issue #2. I have made the change you suggested. However what you say was at line 95 (instance = Graph.Clone<Graph>(originalGraph)
) for me is at line 108. I am wondering if I have the right version of NC now… but I installed from the Asset Store a couple of days ago.
After the change, I still get an exception about “GetComponent” but from a different location:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
A first chance exception of type 'System.InvalidCastException' occurred in mscorlib.ni.dll A first chance exception of type 'System.Runtime.InteropServices.SEHException' occurred in UnityEngine.DLL Exception: External component has thrown an exception. Type: System.Runtime.InteropServices.SEHException Module: UnityEngine InnerException: <No Data> AdditionalInfo:<No Data> at UnityEngine.Internal.$Calli.Invoke123(Int32 arg0, Int32 arg1, Boolean arg2, Boolean arg3, Boolean arg4, Boolean arg5, Int64 arg6, IntPtr method) at UnityEngine.GameObject.GetComponentsInternal(Type type, Boolean useSearchTypeAsArrayReturnType, Boolean recursive, Boolean includeInactive, Boolean reverse, Object resultList) at UnityEngine.GameObject.GetComponents[T]() at NodeCanvas.StateMachines.FSM.GatherDelegates() at NodeCanvas.StateMachines.FSM.OnGraphStarted() at NodeCanvas.Framework.Graph.StartGraph(Component agent, IBlackboard blackboard, Action' 1 callback) at NodeCanvas.Framework.GraphOwner' 1.StartBehaviour() at NodeCanvas.Framework.GraphOwner.Start() at NodeCanvas.Framework.GraphOwner.$Invoke21(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: Line: 0) SEHException: External component has thrown an exception. at UnityEngine.Internal.$Calli.Invoke123(Int32 arg0, Int32 arg1, Boolean arg2, Boolean arg3, Boolean arg4, Boolean arg5, Int64 arg6, IntPtr method) at UnityEngine.GameObject.GetComponentsInternal(Type type, Boolean useSearchTypeAsArrayReturnType, Boolean recursive, Boolean includeInactive, Boolean reverse, Object resultList) at UnityEngine.GameObject.GetComponents[T]() at NodeCanvas.StateMachines.FSM.GatherDelegates() at NodeCanvas.StateMachines.FSM.OnGraphStarted() at NodeCanvas.Framework.Graph.StartGraph(Component agent, IBlackboard blackboard, Action'1 callback) at NodeCanvas.Framework.GraphOwner'1.StartBehaviour() at NodeCanvas.Framework.GraphOwner.Start() at NodeCanvas.Framework.GraphOwner.$Invoke21(Int64 instance, Int64* args) at UnityEngine.Internal.$MethodUtility.InvokeMethod(Int64 instance, Int64* args, IntPtr method) (Filename: <Unknown> Line: 0) |
Sometime over the weekend, I had submitted a bug to Unity about this exact problem. Here is the answer they sent back:
Thank you for reporting the issue.
It appears that you are trying to call the method from the wrong thread. In order for the code to work you have to call it like this:
private void Unity_Loaded()
{UnityPlayer.UnityApp.BeginInvoke(() =>
{
//your code
});}
That makes some sense considering the exception call stack, but after a quick look, I can’t see where the original Invoke would be. Also, why does it even work in the editor/other_platforms it that is the case?
Cheers,
Alain-Daniel
Hello,
Thanks. I think I know the issue now regarding GetComponents.
Considering I’m correct about my speculation, if you comment out GatherDelegates() in FSM.cs at line #42, it should work.
Can you please confirm?
Thanks!
(PS: You certainly have last version if you updated from asset store, the difference in line # was due to the change in ‘graphIsLocal’ property we made here in this post)
Join us on Discord: https://discord.gg/97q2Rjh
Hello,
So I tested commenting GatherDeledate() at line 42. The exception are gone, but not everything is entirely kosher still. I’m getting this error on an ActionNode with a DebugLogText action on it (and the ‘Hello World’ was not sent to the console). Obvisouly, this doesn’t happen in the editor.
1 2 |
<b>Task Error:</b> Failed to change Agent to requested type 'UnityEngine.Transform', for Task 'Debug Log Text' or new Agent is NULL. Does the Agent has the requested Component? (Task Disabled) |
There was also a couple of NullReferenceException trapped by Visual Studio in the debug log before it, but I don’t know if they are related since there always are some of those when running a project through VS.
Cheers,
Alain-Daniel
Hello Daniel,
Sorry of the late reply.
I am still looking into this issue.
Could you please provide the full stack trace of those error logs?
Thanks in advance.
Join us on Discord: https://discord.gg/97q2Rjh
Yep, that was me on Activator.CreateInstance(ReflectedType);
Not using the bool flag fixed crash i was seeing.
(I was seeing that crash on Unity 4.6.1 by the way)
Thanks for letting me know.
Do you mean that even the original issue is solved by this for you?
Thanks
Join us on Discord: https://discord.gg/97q2Rjh
Yep, i can confirm the patch i sent to you fixed the original crash for me.
I think we just need a WP8 defines as METRO only covers WSA i believe.