NodeCanvas Forums › Support › Trouble using C# event of type Action
Hi, I’m trying out C# events using this test:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class CSharpEventTest : MonoBehaviour { public event Action<int> onFiveSecondsElapsed; // Update is called once per frame void Update() { if (Time.time > 5.0f) { onFiveSecondsElapsed.Invoke(123); enabled = false; } } } |
Then in a behavior tree, I’m using Check CSharp Event Value (Integer).
It works fine in the editor, however, thhe WebGL build crashes.
I have already built the AOTClasses.cs and link.xml files. I did not change any of the preferred types. System.Integer is already in the list, so I think it should work. Apparently it doesn’t.
This is part of the error for a developer build:
An error occurred running the Unity content on this page. See your browser JavaScript console for more info. The error was:
uncaught exception: abort(241) at jsStackTrace (WebGL_Developer.asm.framework.unityweb:1154:12)
stackTrace (WebGL_Developer.asm.framework.unityweb:1168:11)
abort (WebGL_Developer.asm.framework.unityweb:21955:43)
nullFunc_iiii (WebGL_Developer.asm.framework.unityweb:16112:2)
b241 (WebGL_Developer.asm.code.unityweb:3118350:1)
_EventInfo_CreateAddEventDelegate_m1446482289 (WebGL_Developer.asm.code.unityweb:1229117:1)
_EventInfo_AddEventHandler_m1121664596 (WebGL_Developer.asm.code.unityweb:1878620:1)
_CheckCSharpEventValue_1_OnInit_m3596319355_gshared (WebGL_Developer.asm.code.unityweb:2077955:1)
_Task_Initialize_m3619201912 (WebGL_Developer.asm.code.unityweb:1700383:1)
_Task_Set_m1259982997 (WebGL_Developer.asm.code.unityweb:1918786:1)
_ConditionTask_CheckCondition_m4251061198 (WebGL_Developer.asm.code.unityweb:2615670:1)
(etc…)
Any ideas what might be wrong? What am I missing? I tested using version 2.8.0.
Hey,
I just wanted to let you know that I am still looking into this problem and will report back to you as soon as I find the cause and fix.
Thank you for your patience!
Join us on Discord: https://discord.gg/97q2Rjh
Thanks! I was using Unity v2017.3.0f3 by the way.
Hi Gavalakis, do you have any news on this? Should I go looking for a workaround?
Hey,
I am really sorry, but unfortunately it seems that I am facing problems with building to WebGL right now unrelated to this error.
Can you please try the attached “patch” and let me know if that resolves the problem you are facing?
Thank you!
Join us on Discord: https://discord.gg/97q2Rjh
Hi Gavalakis, I have tried the package. Unfortunately without success. Below I have pasted the relevant text from the Web Console of Firefox. The error is very similar to the previous one.
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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this) UnityLoader.js:264:40 Build with ASSERTIONS=2 for more info. UnityLoader.js:264:40 228 UnityLoader.js:263:37 228 UnityLoader.js:264:40 Invoking error handler due to uncaught exception: abort(228) at jsStackTrace (WebGL.asm.framework.unityweb:1154:12) stackTrace (WebGL.asm.framework.unityweb:1168:11) abort (WebGL.asm.framework.unityweb:21908:43) nullFunc_iiii (WebGL.asm.framework.unityweb:16226:2) b228 (WebGL.asm.code.unityweb:2695933:1) _EventInfo_CreateAddEventDelegate_m1446482289 (WebGL.asm.code.unityweb:1011187:1) _EventInfo_AddEventHandler_m1121664596 (WebGL.asm.code.unityweb:1594088:1) _CheckCSharpEventValue_1_OnInit_m3596319355_gshared (WebGL.asm.code.unityweb:1768213:1) _Task_Initialize_m3619201912 (WebGL.asm.code.unityweb:1428891:1) _Task_Set_m1259982997 (WebGL.asm.code.unityweb:1627810:1) _ConditionTask_CheckCondition_m4251061198 (WebGL.asm.code.unityweb:2252625:1) _WaitUntil_OnExecute_m3775522078 (WebGL.asm.code.unityweb:2068124:1) _Node_Execute_m796556704 (WebGL.asm.code.unityweb:2259103:1) _BehaviourTree_Tick_m3904527064 (WebGL.asm.code.unityweb:2424932:1) _BehaviourTree_OnGraphUpdate_m1604851717 (WebGL.asm.code.unityweb:2163599:1) _Graph_UpdateGraph_m2413572913 (WebGL.asm.code.unityweb:2568889:1) _Graph_StartGraph_m2584098707 (WebGL.asm.code.unityweb:717191:1) _GraphOwner_StartBehaviour_m353596838 (WebGL.asm.code.unityweb:1802927:1) _GraphOwner_Start_m2172976059 (WebGL.asm.code.unityweb:2610839:1) __Z31RuntimeInvoker_Void_t1185182177PFvvEPK10MethodInfoPvPS4_ (WebGL.asm.code.unityweb:2608326:1) dynCall_iiiii (WebGL.asm.code.unityweb:2610509:1) invoke_iiiii (WebGL.asm.framework.unityweb:16844:10) __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException (WebGL.asm.code.unityweb:2109507:1) _il2cpp_runtime_invoke (WebGL.asm.code.unityweb:2466985:1) __Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb (WebGL.asm.code.unityweb:2276631:1) __ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb (WebGL.asm.code.unityweb:1510350:1) __ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtrP21ScriptingExceptionPtr (WebGL.asm.code.unityweb:387867:1) __ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtr (WebGL.asm.code.unityweb:1462326:1) __ZN13MonoBehaviour16DelayedStartCallEP6ObjectPv (WebGL.asm.code.unityweb:1883619:1) __ZN18DelayedCallManager6UpdateEi (WebGL.asm.code.unityweb:700404:1) __ZZ23InitPlayerLoopCallbacksvEN50EarlyUpdateScriptRunDelayedStartupFrameRegistrator7ForwardEv (WebGL.asm.code.unityweb:2353907:1) __Z10PlayerLoopv (WebGL.asm.code.unityweb:534084:1) __ZL8MainLoopv (WebGL.asm.code.unityweb:1606926:1) dynCall_v (WebGL.asm.code.unityweb:2706201:1) browserIterationFunc (WebGL.asm.framework.unityweb:9490:4) runIter (WebGL.asm.framework.unityweb:8890:5) Browser_mainLoop_runner (WebGL.asm.framework.unityweb:9528:3) UnityLoader.js:568:7 uncaught exception: abort(228) at jsStackTrace@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:1154:12 stackTrace@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:1168:11 abort@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:21908:43 nullFunc_iiii@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:16226:2 b228@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2695933:1 _EventInfo_CreateAddEventDelegate_m1446482289@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1011187:1 _EventInfo_AddEventHandler_m1121664596@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1594088:1 _CheckCSharpEventValue_1_OnInit_m3596319355_gshared@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1768213:1 _Task_Initialize_m3619201912@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1428891:1 _Task_Set_m1259982997@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1627810:1 _ConditionTask_CheckCondition_m4251061198@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2252625:1 _WaitUntil_OnExecute_m3775522078@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2068124:1 _Node_Execute_m796556704@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2259103:1 _BehaviourTree_Tick_m3904527064@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2424932:1 _BehaviourTree_OnGraphUpdate_m1604851717@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2163599:1 _Graph_UpdateGraph_m2413572913@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2568889:1 _Graph_StartGraph_m2584098707@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:717191:1 _GraphOwner_StartBehaviour_m353596838@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1802927:1 _GraphOwner_Start_m2172976059@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2610839:1 __Z31RuntimeInvoker_Void_t1185182177PFvvEPK10MethodInfoPvPS4_ [RuntimeInvoker_Void_t1185182177(void (*)(), MethodInfo const*, void*, void**)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2608326:1 dynCall_iiiii@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2610509:1 invoke_iiiii@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:16844:10 __ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException [il2cpp::vm::Runtime::Invoke(MethodInfo const*, void*, void**, Il2CppException**)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2109507:1 _il2cpp_runtime_invoke@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2466985:1 __Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb [scripting_method_invoke(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingArguments&, ScriptingExceptionPtr*, bool)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2276631:1 __ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb [ScriptingInvocation::Invoke(ScriptingExceptionPtr*, bool)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1510350:1 __ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtrP21ScriptingExceptionPtr [MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr, ScriptingExceptionPtr*)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:387867:1 __ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtr [MonoBehaviour::InvokeMethodOrCoroutineChecked(ScriptingMethodPtr, ScriptingObjectPtr)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1462326:1 __ZN13MonoBehaviour16DelayedStartCallEP6ObjectPv [MonoBehaviour::DelayedStartCall(Object*, void*)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1883619:1 __ZN18DelayedCallManager6UpdateEi [DelayedCallManager::Update(int)]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:700404:1 __ZZ23InitPlayerLoopCallbacksvEN50EarlyUpdateScriptRunDelayedStartupFrameRegistrator7ForwardEv [InitPlayerLoopCallbacks()::EarlyUpdateScriptRunDelayedStartupFrameRegistrator::Forward()]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2353907:1 __Z10PlayerLoopv [PlayerLoop()]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:534084:1 __ZL8MainLoopv [MainLoop()]@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:1606926:1 dynCall_v@blob:http://localhost:52694/3b8141b2-f8c8-4520-9cc6-db64e347d445:2706201:1 browserIterationFunc@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:9490:4 runIter@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:8890:5 Browser_mainLoop_runner@blob:http://localhost:52694/09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:9528:3 unreachable code after return statement[Learn More] 09d320ec-fe50-4bd8-b1c8-2efc5c4f153c:176:2 |
Hello again and sorry for the late reply.
Unfortunately I am still not able to fix this, due to the issues I am facing in building to WebGL in the first place.
I am really sorry about this!
As an alternative solution until this is fixed, I would suggest to please create a custom condition that subscribes to the event directly.
If you need exact code for making such a custom condition, please let me know and I gladly do so.
Once again, I am really sorry for the issue and the lack of fix until now.
Join us on Discord: https://discord.gg/97q2Rjh
Thanks for your response. I will create a custom condition as a workaround.