我们正在开发一款使用MonoGame的游戏,它与MonoTouch 5.2.x一直运行良好,直到更新到5.3.x beta,甚至5.3.5.
加载我们的第一级时游戏会锁定,只有在设备的发布模式下编译时才会发生.在模拟器中或在设备的调试模式下正常工作.
我们不知道问题是什么,直到我们使用了一个技巧Rolf Kvinge发布here.
以下是崩溃日志的有用片段:
0 libsystem_c.dylib 0x32bd68b0 memset$VARIANT$CortexA9 + 152
1 DrawAStickmaniPhone 0x00492e40 DrawAStickmanCore_System_Collections_Generic_Dictionary_2_int_DrawAStickman_Core_Json_Frame_TryGetValue_int_DrawAStickman_Core_Json_Frame_ (DrawAStickmanCore.dll.7.s:36462)
2 DrawAStickmaniPhone 0x004d4e3c DrawAStickman_Core_FrameCounter_OnFrameChanged (DrawAStickmanCore.dll.7.s:137904)
3 DrawAStickmaniPhone 0x00479dbc DrawAStickmanCore_DrawAStickman_Core_BaseCounter_Update_Microsoft_Xna_Framework_GameTime (DrawAStickmanCore.dll.7.s:974)
4 DrawAStickmaniPhone 0x0048694c DrawAStickmanCore_DrawAStickman_Core_ElementStateComponent_Update_Microsoft_Xna_Framework_GameTime (DrawAStickmanCore.dll.7.s:17895)
5 DrawAStickmaniPhone 0x0047ce70 DrawAStickmanCore_DrawAStickman_Core_ElementComponent_Update_Microsoft_Xna_Framework_GameTime (DrawAStickmanCore.dll.7.s:5028)
6 DrawAStickmaniPhone 0x004d72cc DrawAStickman_Core_LevelComponent_Update_Microsoft_Xna_Framework_GameTime_0 (DrawAStickmanCore.dll.7.s:138769)
7 DrawAStickmaniPhone 0x0003d170 MonoGame_Framework_Microsoft_Xna_Framework_Game__UpdateActionm__2C_Microsoft_Xna_Framework_IUpdateable_Microsoft_Xna_Framework_GameTime (MonoGame.Framework.dll.7.s:69150)
8 DrawAStickmaniPhone 0x0003d284 MonoGame_Framework_Microsoft_Xna_Framework_Game_SortingFilteringCollection_1_ForEachFilteredItem_TUserData_System_Action_2_T_TUserData_TUserData (MonoGame.Framework.dll.7.s:69246)
9 DrawAStickmaniPhone 0x0003c3bc MonoGame_Framework_Microsoft_Xna_Framework_Game_Update_Microsoft_Xna_Framework_GameTime (MonoGame.Framework.dll.7.s:67887)
10 DrawAStickmaniPhone 0x004c7664 DrawAStickman_Core_StickmanGame_Update_Microsoft_Xna_Framework_GameTime (DrawAStickmanCore.dll.7.s:133288)
11 DrawAStickmaniPhone 0x0003c674 MonoGame_Framework_Microsoft_Xna_Framework_Game_DoUpdate_Microsoft_Xna_Framework_GameTime (MonoGame.Framework.dll.7.s:68138)
12 DrawAStickmaniPhone 0x0003c284 MonoGame_Framework_Microsoft_Xna_Framework_Game_Tick (MonoGame.Framework.dll.7.s:67751)
13 DrawAStickmaniPhone 0x0003e43c MonoGame_Framework_Microsoft_Xna_Framework_iOSGamePlatform_RunTick (MonoGame.Framework.dll.7.s:70871)
14 DrawAStickmaniPhone 0x0003e39c MonoGame_Framework_Microsoft_Xna_Framework_iOSGamePlatform_Tick (MonoGame.Framework.dll.7.s:70820)
15 DrawAStickmaniPhone 0x002fe8c0 monotouch_MonoTouch_Foundation_NSActionDispatcher_Apply + 12
16 DrawAStickmaniPhone 0x006de878 wrapper_runtime_invoke_object_runtime_invoke_dynamic_intptr_intptr_intptr_intptr_0 (mscorlib.dll.7.s:468944)
17 DrawAStickmaniPhone 0x00963780 mono_jit_runtime_invoke (mini.c:5792)
18 DrawAStickmaniPhone 0x009cdc04 mono_runtime_invoke (object.c:2788)
19 DrawAStickmaniPhone 0x0095aba4 native_to_managed_trampoline_MonoTouch_Foundation_NSActionDispatcher_Apply (registrar.m:19)
看着这个,似乎在这样一条线上陷入僵局:
Frame frame;
if (myFramesDictionary != null && myFramesDictionary.TryGetValue(index, out frame))
{
//Some code here
}
Frame是一个结构,myFramesDictionary是一个Dictionary< int,Frame>.
这是MonoTouch 5.3.x中可能存在的错误吗?我不知道如何在不将整个应用程序发送给Xamarin的情况下重新创建问题.
UPDATE
我们禁用了LLVM编译器选项并修复了挂起.
我无法创建一个小项目来重现这个问题.我不确定是否要将整个应用程序发送到Xamarin进行调试.关于重新创建这个的任何想法?
最佳答案 除非你有一些非常奇怪的内存损坏,否则你不会在memset中死锁.
此外,要诊断死锁,你需要显示多个线程,因为你需要至少两个线程在第一位死锁:)
我相信你正在遇到某种无限循环.您可以使用调试器中的断点或崩溃报告中第1帧开头的Console.WriteLine轻松检查此项.