多线程渲染仅在 iOS 13 时崩溃
Multithreaded rendering only crashes on iOS 13
在我的游戏引擎中,我可以选择启用多线程渲染。
在 iOS 12(及以下)我的应用程序没有崩溃。
我没有更改我的代码中的任何内容,但它在 iOS 13.
时崩溃了
2019-10-02 11:36:07.931 SimpleGame[293:11150] ---> (Inner Exception #0) Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: threading violation: expected the main thread
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 0 CoreFoundation 0x00000001aace1c44 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 1256516
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 1 libobjc.A.dylib 0x00000001aa9fc0c8 objc_exception_throw + 60
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 2 CoreFoundation 0x00000001aabde75c 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 194396
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 3 Foundation 0x00000001ab01f960 672CF0CB-4951-3B91-89DF-55E953AEA00F + 571744
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 4 FrontBoardServices 0x00000001afe9791c 124B166D-3905-3F51-A46A-646AE3424213 + 366876
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 5 FrontBoardServices 0x00000001afe4a288 124B166D-3905-3F51-A46A-646AE3424213 + 49800
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 6 UIKitCore 0x00000001ae51a87c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1915004
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 7 UIKitCore 0x00000001ae517554 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1901908
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 8 UIKitCore 0x00000001ae5177b4 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1902516
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 9 UIKitCore 0x00000001aeface14 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 13000212
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 10 UIKitCore 0x00000001aedaf02c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10911788
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 11 UIKitCore 0x00000001aedaff00 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10915584
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 12
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 22 SimpleGame 0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 23 SimpleGame 0x00000001048b45e8 World_FlushRenderWorkQueue_private + 2808016
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 24 SimpleGame 0x00000001048b54c0 World_FlushRenderWorkQueue_private + 2811816
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 25 SimpleGame 0x00000001051d7198 World_FlushRenderWorkQueue_private + 12387456
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 26 SimpleGame 0x000000010503c058 World_FlushRenderWorkQueue_private + 10703680
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 27 SimpleGame 0x000000010503b774 World_FlushRenderWorkQueue_private + 10701404
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 28 SimpleGame 0x00000001051d5400 World_FlushRenderWorkQueue_private + 12379880
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 29 SimpleGame 0x000000010487d904 World_FlushRenderWorkQueue_private + 2583532
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 30 SimpleGame 0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 31 SimpleGame 0x000000010487c038 World_FlushRenderWorkQueue_private + 2577184
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 32 SimpleGame 0x000000010487da00 World_FlushRenderWorkQueue_private + 2583784
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 33 SimpleGame 0x00000001047081a8 World_FlushRenderWorkQueue_private + 1053840
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 34 SimpleGame 0x0000000105bb1434 World_FlushRenderWorkQueue_private + 22718236
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 35 SimpleGame 0x0000000105c18dd4 World_FlushRenderWorkQueue_private + 23142588
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 36 PSimpleGame 0x0000000105c44080 World_FlushRenderWorkQueue_private + 23319400
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 37 libsystem_pthread.dylib 0x00000001aa9ecd5c _pthread_start + 128
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 38 libsystem_pthread.dylib 0x00000001aa9f4c84 thread_start + 8
当我禁用多线程渲染选项时,它没有崩溃。
iOS 13 中的线程系统一定有变化,但无法从他们的文档中找到任何内容。
正如 Gene 所说,问题是当您从后台线程错误地与 UI 交互时,iOS 的早期版本不会停止。 iOS13个会。
为了帮助确定问题,请转到“编辑器”»“方案”»“编辑方案...”,然后检查“主线程检查器”。如果你点击旁边的右箭头,它甚至会为问题创建一个断点,它会在你试图从后台线程更新 UI 的那一行停止执行:
在我的游戏引擎中,我可以选择启用多线程渲染。 在 iOS 12(及以下)我的应用程序没有崩溃。
我没有更改我的代码中的任何内容,但它在 iOS 13.
时崩溃了2019-10-02 11:36:07.931 SimpleGame[293:11150] ---> (Inner Exception #0) Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: threading violation: expected the main thread
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 0 CoreFoundation 0x00000001aace1c44 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 1256516
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 1 libobjc.A.dylib 0x00000001aa9fc0c8 objc_exception_throw + 60
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 2 CoreFoundation 0x00000001aabde75c 97285ACB-7B21-393A-ABF6-03F1DBB5D2A2 + 194396
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 3 Foundation 0x00000001ab01f960 672CF0CB-4951-3B91-89DF-55E953AEA00F + 571744
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 4 FrontBoardServices 0x00000001afe9791c 124B166D-3905-3F51-A46A-646AE3424213 + 366876
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 5 FrontBoardServices 0x00000001afe4a288 124B166D-3905-3F51-A46A-646AE3424213 + 49800
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 6 UIKitCore 0x00000001ae51a87c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1915004
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 7 UIKitCore 0x00000001ae517554 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1901908
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 8 UIKitCore 0x00000001ae5177b4 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 1902516
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 9 UIKitCore 0x00000001aeface14 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 13000212
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 10 UIKitCore 0x00000001aedaf02c 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10911788
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 11 UIKitCore 0x00000001aedaff00 55D60569-DBB7-3BC9-8A97-DCAC95C64D4B + 10915584
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 12
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 22 SimpleGame 0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 23 SimpleGame 0x00000001048b45e8 World_FlushRenderWorkQueue_private + 2808016
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 24 SimpleGame 0x00000001048b54c0 World_FlushRenderWorkQueue_private + 2811816
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 25 SimpleGame 0x00000001051d7198 World_FlushRenderWorkQueue_private + 12387456
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 26 SimpleGame 0x000000010503c058 World_FlushRenderWorkQueue_private + 10703680
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 27 SimpleGame 0x000000010503b774 World_FlushRenderWorkQueue_private + 10701404
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 28 SimpleGame 0x00000001051d5400 World_FlushRenderWorkQueue_private + 12379880
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 29 SimpleGame 0x000000010487d904 World_FlushRenderWorkQueue_private + 2583532
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 30 SimpleGame 0x000000010487c2a4 World_FlushRenderWorkQueue_private + 2577804
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 31 SimpleGame 0x000000010487c038 World_FlushRenderWorkQueue_private + 2577184
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 32 SimpleGame 0x000000010487da00 World_FlushRenderWorkQueue_private + 2583784
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 33 SimpleGame 0x00000001047081a8 World_FlushRenderWorkQueue_private + 1053840
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 34 SimpleGame 0x0000000105bb1434 World_FlushRenderWorkQueue_private + 22718236
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 35 SimpleGame 0x0000000105c18dd4 World_FlushRenderWorkQueue_private + 23142588
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 36 PSimpleGame 0x0000000105c44080 World_FlushRenderWorkQueue_private + 23319400
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 37 libsystem_pthread.dylib 0x00000001aa9ecd5c _pthread_start + 128
Oct 2 09:57:48 GL04207-MT SimpleGame[923] <Notice>: 38 libsystem_pthread.dylib 0x00000001aa9f4c84 thread_start + 8
当我禁用多线程渲染选项时,它没有崩溃。 iOS 13 中的线程系统一定有变化,但无法从他们的文档中找到任何内容。
正如 Gene 所说,问题是当您从后台线程错误地与 UI 交互时,iOS 的早期版本不会停止。 iOS13个会。
为了帮助确定问题,请转到“编辑器”»“方案”»“编辑方案...”,然后检查“主线程检查器”。如果你点击旁边的右箭头,它甚至会为问题创建一个断点,它会在你试图从后台线程更新 UI 的那一行停止执行: