从直接c#和jslib回调c调用事件时,会调用不同的函数签名#

从直接c#和jslib回调c调用事件时,会调用不同的函数签名#,c#,unity3d,unity-webgl,asm.js,C#,Unity3d,Unity Webgl,Asm.js,我正在从事一个Unity项目,处理WebGL插件,Unity称之为“jslib” 虽然unity建议在jslib与c#交互时使用UnitySendMessage,但我更喜欢使用委托作为回调。在一个小的测试代码中,它起了作用。但当它运行到触发事件代码时,会发生奇怪的错误 c#: 调用UserLoginDispatcher中的ProcessLoginOver时,测试中的onLoginOver会抛出错误: 使用签名“viiii”调用的函数指针无效。可能这是一个无效值(例如,对空指针调用虚拟方法导致)?

我正在从事一个Unity项目,处理WebGL插件,Unity称之为“jslib”

虽然unity建议在jslib与c#交互时使用UnitySendMessage,但我更喜欢使用委托作为回调。在一个小的测试代码中,它起了作用。但当它运行到触发事件代码时,会发生奇怪的错误

c#:

调用UserLoginDispatcher中的ProcessLoginOver时,测试中的onLoginOver会抛出错误:

使用签名“viiii”调用的函数指针无效。可能这是一个无效值(例如,对空指针调用虚拟方法导致)?或者调用类型不正确的函数会失败?(值得使用-Werror构建源文件(警告是错误),因为警告可能表示可能导致此问题的未定义行为)

但如果我尝试直接用c#代码调用此事件,它可以成功触发

错误调用堆栈:

Uncaught abort(68) at Error
at jsStackTrace (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23794:12)
at stackTrace (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23808:11)
at abort (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:464638:43)
at nullFunc_viiii (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:50912:2)
at Array.b68 (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:455121:2)
at ftCall_viiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:6602:49)
at mftCall_viiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:732323:2)
at _UserLoginCallback_Invoke_m2599958513 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:533179:4)
at _UserLoginCallback_Invoke_m2599958513 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:533170:14)
at _UserLoginDispatcher_ProcessLoginOver_m2254139378 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:562185:2)
at _WebGLPluginManager_OnLoginOver_m1528063286 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:548824:2)
at Array.asm._WebGLPluginManager_OnLoginOver_m1528063286 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:921460:59)
....
错误时取消捕获中止(68)
在jsStackTrace(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23794:12)
在stackTrace(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23808:11)
中止时(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:464638:43)
在nullFunc_viiii(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:50912:2)
在Array.b68(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:455121:2)
在ftCall_viiii(装载时评估动态图书馆(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:6602:49)
在mftCall_viiii(在负荷动态库进行评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:732323:2)
在_UserLoginCallback _Invoke _m2599958513(在loadDynamicLibrary(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:533179:4)
在_UserLoginCallback _Invoke _m2599958513(在loadDynamicLibrary(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:533170:14)
在\u UserLoginDispatcher\u ProcessLoginOver\u m2254139378(在loadDynamicLibrary(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:562185:2)
在(网址:WebGLPluginManager)OnLoginOver(网址:m1528063286)(在loadDynamicLibrary进行评估)http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:548824:2)
在Array.asm.\u WebGLPluginManager\u OnLoginOver\u m1528063286(在loadDynamicLibrary(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:921460:59)
....
直接c#call的堆栈

使用上下文登录测试会话12:13:28,pluginId DefaultUserLogin,errmsg:
在uuu Z13GetStacktracei[GetStacktrace(int)](blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825BF3:2275897:2)
在u Z17DebugStringToFileRK21DebugStringToFileData[DebugStringToFile(DebugStringToFileData const&)](blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825BF3:1247009:5)
在uuuuz17debugStringToFilePKCIS0_i15LogMessageFlagsiiPFvRK11CppLogEntryE[DebugStringToFile(char const*,int,char const*,int,LogMessageFlags,int,int,void(*)(CppLogEntry const&))(blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825BF3:2562904:2)
在uuuuu Z35DebugLogHandler\u CUSTOM\u Internal\u log7logtype12il2cppstringp12il2cppobject[DebugLogHandler\u CUSTOM\u Internal\u Log(LogType,Il2CppString*,Il2CppObject*)(blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825BF3:2126846:2)
位于Array.UnityLoader.d9fd6255ccad354c9cc5ad72abf13dcc.asm.\uuuuuz35debugloghandler\u CUSTOM\u Internal\u log7logtype12il2cppstringp12il2cppobject[DebugLogHandler\u CUSTOM\u Internal\u Log(LogType,Il2CppString*,Il2CppObject*)](blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:145057:93)
在ftCall_viii时(在loadDynamicLibrary时评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:7197:48)
在mftCall_viii(装载时的评估动态图书馆(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:747533:2)
在调试日志处理程序内部日志m1116757358处(在loadDynamicLibrary处评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:719622:2)
在阵列处。_DebugLogHandler_LogFormat_m2613962716(在loadDynamicLibrary处评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:620933:2)
在mftCall_viiiiii处(装载时的评估动态图书馆(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:708880:40)
在uuzn23InterfaceActionInvoker4IIP18Object_t3753624189P8String_tP24ObjectU5BU5D_T2405707486E6InvokeeJP11Il2CppClassP12Il2CppObjects1_S3_S5_u2;[InterfaceActionInvoker4::Invoke(未签名的int、Il2CppClass*、Il2CppObject*、int、Object_t3753624189*、String_t*、ObjectU5BU5D_t2405707486*))(在loadDynamicLibrary处评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:394923:2)
阵列处。_Logger_Log_m314997607(负载动态库处的评估(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:564686:3)
在mftCall_viiii(在负荷动态库进行评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:732320:39)
在uuu ZN23InterfaceActionInvoker2IiP12Il2CppObjectE6InvokeEjP11Il2CppClassS1_uu1[InterfaceActionInvoker2::Invoke(unsigned int,Il2CppClass*,Il2CppObject*,int,Il2CppObject*)(在loadDynamicLibrary时求值(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:412747:2)
在调试日志处,m2324883804(负载动态库处的评估)(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:619913:2)
at测试日志格式m983122927(负载时评估动态数据库(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:579589:2)
在阵列上进行测试,仅在OGINOVER m2512123873(在负载动态库进行评估(blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19),:383768:2)
在mftCall_viiiii(装载时的评估)
...//login succeed:
Runtime.dynCall("viiiii", .....);
Uncaught abort(68) at Error
at jsStackTrace (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23794:12)
at stackTrace (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23808:11)
at abort (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:464638:43)
at nullFunc_viiii (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:50912:2)
at Array.b68 (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:455121:2)
at ftCall_viiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:6602:49)
at mftCall_viiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:732323:2)
at _UserLoginCallback_Invoke_m2599958513 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:533179:4)
at _UserLoginCallback_Invoke_m2599958513 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:533170:14)
at _UserLoginDispatcher_ProcessLoginOver_m2254139378 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:562185:2)
at _WebGLPluginManager_OnLoginOver_m1528063286 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:548824:2)
at Array.asm._WebGLPluginManager_OnLoginOver_m1528063286 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:921460:59)
....
Login Over with context a test session 12:13:28, pluginId DefaultUserLogin, errmsg:
at __Z13GetStacktracei [GetStacktrace(int)] (blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825bff3:2275897:2)
at __Z17DebugStringToFileRK21DebugStringToFileData [DebugStringToFile(DebugStringToFileData const&)] (blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825bff3:1247009:5)
at __Z17DebugStringToFilePKciS0_i15LogMessageFlagsiiPFvRK11CppLogEntryE [DebugStringToFile(char const*, int, char const*, int, LogMessageFlags, int, int, void (*)(CppLogEntry const&))] (blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825bff3:2562904:2)
at __Z35DebugLogHandler_CUSTOM_Internal_Log7LogTypeP12Il2CppStringP12Il2CppObject [DebugLogHandler_CUSTOM_Internal_Log(LogType, Il2CppString*, Il2CppObject*)] (blob:http://localhost:60912/6467252d-2f87-4a2c-9967-31868825bff3:2126846:2)
at Array.UnityLoader.d9fd6255ccad354c9cc5ad72abf13dcc.asm.__Z35DebugLogHandler_CUSTOM_Internal_Log7LogTypeP12Il2CppStringP12Il2CppObject [DebugLogHandler_CUSTOM_Internal_Log(LogType, Il2CppString*, Il2CppObject*)] (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:145057:93)
at ftCall_viii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:7197:48)
at mftCall_viii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:747533:2)
at _DebugLogHandler_Internal_Log_m1116757358 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:719622:2)
at Array._DebugLogHandler_LogFormat_m2613962716 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:620933:2)
at mftCall_viiiiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:708880:40)
at __ZN23InterfaceActionInvoker4IiP18Object_t3753624189P8String_tP24ObjectU5BU5D_t2405707486E6InvokeEjP11Il2CppClassP12Il2CppObjectiS1_S3_S5_ [InterfaceActionInvoker4<int, Object_t3753624189*, String_t*, ObjectU5BU5D_t2405707486*>::Invoke(unsigned int, Il2CppClass*, Il2CppObject*, int, Object_t3753624189*, String_t*, ObjectU5BU5D_t2405707486*)] (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:394923:2)
at Array._Logger_Log_m314997607 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:564686:3)
at mftCall_viiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:732320:39)
at __ZN23InterfaceActionInvoker2IiP12Il2CppObjectE6InvokeEjP11Il2CppClassS1_iS1_ [InterfaceActionInvoker2<int, Il2CppObject*>::Invoke(unsigned int, Il2CppClass*, Il2CppObject*, int, Il2CppObject*)] (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:412747:2)
at _Debug_Log_m2324883804 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:619913:2)
at _Test_LogFormat_m983122927 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:579589:2)
at Array._Test_onLoginOver_m2512123873 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:383768:2)
at mftCall_viiiii (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:720078:40)
at _UserLoginCallback_Invoke_m2599958513 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:533182:4)
at _UserLoginDispatcher_ProcessLoginOver_m2254139378 (eval at loadDynamicLibrary (blob:http://localhost:60912/134eecaa-92a2-4615-b5b2-0a2ab6d2ed73:23235:19), <anonymous>:562185:2)
....